1 /* { dg-do run } */
2 /* { dg-options "-mips16 -mcode-readable=yes" } */
3
4 /* PR tree-optimization/51513 verification variant for MIPS16, #2. */
5
6 int __attribute__ ((weak))
frob(int i)7 frob (int i)
8 {
9 switch (i)
10 {
11 case -5:
12 return -2;
13 case -3:
14 return -1;
15 case 0:
16 return 0;
17 case 3:
18 return 1;
19 case 5:
20 break;
21 default:
22 __builtin_unreachable ();
23 }
24 return i;
25 }
26
27 int
main(void)28 main (void)
29 {
30 return !(frob (-5) == -2
31 & frob (-3) == -1
32 & frob (0) == 0
33 & frob (3) == 1
34 & frob (5) == 5);
35 }
36
37 /* Without the fix for PR tree-optimization/51513 truncated code
38 would be emitted for `frob', like:
39
40 .text
41 .align 2
42 .weak frob
43 .set mips16
44 .set nomicromips
45 .ent frob
46 .type frob, @function
47 frob:
48 .frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, gp= 0
49 .mask 0x00000000,0
50 .fmask 0x00000000,0
51 addiu $2,$4,5
52 .end frob
53 .size frob, .-frob
54
55 meaning `frob' will have no chance to return, let alone produce
56 the result expected. */
57