2017-12-05 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / pr69097-1.c
blob0c20764128e9e9217de60c41d0c4f09b0fe90df4
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" } } */
8 int
9 f1 (int x, int y)
11 if (x == -__INT_MAX__ - 1)
12 __builtin_unreachable ();
13 return x % -y;
16 int
17 f2 (int x, int y)
19 if (x < -__INT_MAX__)
20 __builtin_unreachable ();
21 return x % -y;
24 int
25 f3 (int x, int y)
27 if (y == -1)
28 __builtin_unreachable ();
29 return x % -y;
32 int
33 f4 (int x, int y)
35 if (y < 0)
36 __builtin_unreachable ();
37 return x % -y;
40 int
41 f5 (int x, int y)
43 if (y >= -1)
44 __builtin_unreachable ();
45 return x % -y;
48 int
49 f6 (int x, int y)
51 if (y < 0 || y > 24)
52 __builtin_unreachable ();
53 return x % -y;
56 int
57 f7 (int x, int y)
59 if (y <= -17 || y >= -1)
60 __builtin_unreachable ();
61 return x % -y;
64 int
65 f8 (int x, int y)
67 if (y >= -13 && y <= 15)
68 __builtin_unreachable ();
69 return x % -y;
72 int
73 f9 (int x, int y)
75 return x % -(y & ~4);
78 int
79 f10 (int x, int y)
81 if (x != -__INT_MAX__ - 1)
82 return x % -y;
83 return 34;
86 int
87 f11 (int x, int y)
89 if (x >= -__INT_MAX__)
90 return x % -y;
91 return 34;
94 int
95 f12 (int x, int y)
97 if (y != -1)
98 return x % -y;
99 return 34;
103 f13 (int x, int y)
105 if (y >= 0)
106 return x % -y;
107 return 34;
111 f14 (int x, int y)
113 if (y < -1)
114 return x % -y;
115 return 34;
119 f15 (int x, int y)
121 if (y >= 0 && y <= 24)
122 return x % -y;
123 return 34;
127 f16 (int x, int y)
129 if (y > -17 && y < -1)
130 return x % -y;
131 return 34;
135 f17 (int x, int y)
137 if (y < -13 || y > 15)
138 return x % -y;
139 return 34;