1 /* PR tree-optimization/69097 */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -fdump-tree-optimized" } */
4 /* All the x % -y below should be optimized into x % y, as
5 it should never be INT_MIN % -(-1). */
6 /* { dg-final { scan-tree-dump-not "-y" "optimized" } } */
7
8 int
f1(int x,int y)9 f1 (int x, int y)
10 {
11 if (x == -__INT_MAX__ - 1)
12 __builtin_unreachable ();
13 return x % -y;
14 }
15
16 int
f2(int x,int y)17 f2 (int x, int y)
18 {
19 if (x < -__INT_MAX__)
20 __builtin_unreachable ();
21 return x % -y;
22 }
23
24 int
f3(int x,int y)25 f3 (int x, int y)
26 {
27 if (y == -1)
28 __builtin_unreachable ();
29 return x % -y;
30 }
31
32 int
f4(int x,int y)33 f4 (int x, int y)
34 {
35 if (y < 0)
36 __builtin_unreachable ();
37 return x % -y;
38 }
39
40 int
f5(int x,int y)41 f5 (int x, int y)
42 {
43 if (y >= -1)
44 __builtin_unreachable ();
45 return x % -y;
46 }
47
48 int
f6(int x,int y)49 f6 (int x, int y)
50 {
51 if (y < 0 || y > 24)
52 __builtin_unreachable ();
53 return x % -y;
54 }
55
56 int
f7(int x,int y)57 f7 (int x, int y)
58 {
59 if (y <= -17 || y >= -1)
60 __builtin_unreachable ();
61 return x % -y;
62 }
63
64 int
f8(int x,int y)65 f8 (int x, int y)
66 {
67 if (y >= -13 && y <= 15)
68 __builtin_unreachable ();
69 return x % -y;
70 }
71
72 int
f9(int x,int y)73 f9 (int x, int y)
74 {
75 return x % -(y & ~4);
76 }
77
78 int
f10(int x,int y)79 f10 (int x, int y)
80 {
81 if (x != -__INT_MAX__ - 1)
82 return x % -y;
83 return 34;
84 }
85
86 int
f11(int x,int y)87 f11 (int x, int y)
88 {
89 if (x >= -__INT_MAX__)
90 return x % -y;
91 return 34;
92 }
93
94 int
f12(int x,int y)95 f12 (int x, int y)
96 {
97 if (y != -1)
98 return x % -y;
99 return 34;
100 }
101
102 int
f13(int x,int y)103 f13 (int x, int y)
104 {
105 if (y >= 0)
106 return x % -y;
107 return 34;
108 }
109
110 int
f14(int x,int y)111 f14 (int x, int y)
112 {
113 if (y < -1)
114 return x % -y;
115 return 34;
116 }
117
118 int
f15(int x,int y)119 f15 (int x, int y)
120 {
121 if (y >= 0 && y <= 24)
122 return x % -y;
123 return 34;
124 }
125
126 int
f16(int x,int y)127 f16 (int x, int y)
128 {
129 if (y > -17 && y < -1)
130 return x % -y;
131 return 34;
132 }
133
134 int
f17(int x,int y)135 f17 (int x, int y)
136 {
137 if (y < -13 || y > 15)
138 return x % -y;
139 return 34;
140 }
141