1 /* PR tree-optimization/66187 */
2 /* { dg-do run } */
3 /* { dg-options "-O2 -fwrapv" } */
4
5 __attribute__((noinline, noclone)) int
f0(unsigned char x,unsigned char y)6 f0 (unsigned char x, unsigned char y)
7 {
8 return (x + y) & 0x2ff;
9 }
10
11 __attribute__((noinline, noclone)) int
f1(unsigned char x,unsigned char y)12 f1 (unsigned char x, unsigned char y)
13 {
14 return (x - y) & 0x2ff;
15 }
16
17 __attribute__((noinline, noclone)) int
f2(signed char x,signed char y)18 f2 (signed char x, signed char y)
19 {
20 return (x + y) & -4;
21 }
22
23 __attribute__((noinline, noclone)) int
f3(signed char x,signed char y)24 f3 (signed char x, signed char y)
25 {
26 return (x + y) & 0xf8;
27 }
28
29 __attribute__((noinline, noclone)) int
f4(signed char x,signed char y)30 f4 (signed char x, signed char y)
31 {
32 return (x + y) & 0x78;
33 }
34
35 __attribute__((noinline, noclone)) int
f5(unsigned char x,unsigned char y)36 f5 (unsigned char x, unsigned char y)
37 {
38 int a = x;
39 int b = y;
40 int c = a + b;
41 return c & 0x2ff;
42 }
43
44 __attribute__((noinline, noclone)) int
f6(unsigned char x,unsigned char y)45 f6 (unsigned char x, unsigned char y)
46 {
47 int a = x;
48 int b = y;
49 int c = a - b;
50 return c & 0x2ff;
51 }
52
53 __attribute__((noinline, noclone)) int
f7(signed char x,signed char y)54 f7 (signed char x, signed char y)
55 {
56 int a = x;
57 int b = y;
58 int c = a + b;
59 return c & -4;
60 }
61
62 __attribute__((noinline, noclone)) int
f8(signed char x,signed char y)63 f8 (signed char x, signed char y)
64 {
65 int a = x;
66 int b = y;
67 int c = a + b;
68 return c & 0xf8;
69 }
70
71 __attribute__((noinline, noclone)) int
f9(signed char x,signed char y)72 f9 (signed char x, signed char y)
73 {
74 int a = x;
75 int b = y;
76 int c = a + b;
77 return c & 0x78;
78 }
79
80 int
main()81 main ()
82 {
83 if (__SCHAR_MAX__ != 127 || sizeof (int) != 4)
84 return 0;
85 if (f0 (0xff, 0xff) != 0xfe
86 || f1 (0, 1) != 0x2ff
87 || f2 (-2, 1) != -4
88 || f3 (-2, 1) != 0xf8
89 || f4 (-2, 1) != 0x78
90 || f5 (0xff, 0xff) != 0xfe
91 || f6 (0, 1) != 0x2ff
92 || f7 (-2, 1) != -4
93 || f8 (-2, 1) != 0xf8
94 || f9 (-2, 1) != 0x78)
95 __builtin_abort ();
96 return 0;
97 }
98