Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.dg / pr68513.c
blob86f878d5d73533e5da0f5713236e0465f4cda078
1 /* PR c/68513 */
2 /* { dg-do compile } */
3 /* { dg-options "-funsafe-math-optimizations -fno-math-errno -O -Wno-div-by-zero" } */
5 int i;
6 unsigned u;
7 volatile int *e;
9 #define E (i ? *e : 0)
11 /* Can't trigger some of them because operand_equal_p will return false
12 for side-effects. */
14 /* (x & ~m) | (y & m) -> ((x ^ y) & m) ^ x */
15 int
16 fn1 (void)
18 int r = 0;
19 r += (short) (E & ~u | i & u);
20 r += -(short) (E & ~u | i & u);
21 r += (short) -(E & ~u | i & u);
22 return r;
25 /* sqrt(x) < y is x >= 0 && x != +Inf, when y is large. */
26 double
27 fn2 (void)
29 double r;
30 r = __builtin_sqrt (E) < __builtin_inf ();
31 return r;
34 /* sqrt(x) < c is the same as x >= 0 && x < c*c. */
35 double
36 fn3 (void)
38 double r;
39 r = __builtin_sqrt (E) < 1.3;
40 return r;
43 /* copysign(x,y)*copysign(x,y) -> x*x. */
44 double
45 fn4 (double y, double x)
47 return __builtin_copysign (E, y) * __builtin_copysign (E, y);
50 /* x <= +Inf is the same as x == x, i.e. !isnan(x). */
51 int
52 fn5 (void)
54 return E <= __builtin_inf ();
57 /* Fold (A & ~B) - (A & B) into (A ^ B) - B. */
58 int
59 fn6 (void)
61 return (i & ~E) - (i & E);
64 /* Fold (A & B) - (A & ~B) into B - (A ^ B). */
65 int
66 fn7 (void)
68 return (i & E) - (i & ~E);
71 /* x + (x & 1) -> (x + 1) & ~1 */
72 int
73 fn8 (void)
75 return E + (E & 1);
78 /* Simplify comparison of something with itself. */
79 int
80 fn9 (void)
82 return E <= E | E >= E;
85 /* Fold (A & ~B) - (A & B) into (A ^ B) - B. */
86 int
87 fn10 (void)
89 return (i & ~E) - (i & E);
92 /* abs(x)*abs(x) -> x*x. Should be valid for all types. */
93 int
94 fn11 (void)
96 return __builtin_abs (E) * __builtin_abs (E);
99 /* (x | CST1) & CST2 -> (x & CST2) | (CST1 & CST2) */
101 fn12 (void)
103 return (E | 11) & 12;
106 /* fold_range_test */
108 fn13 (const char *s)
110 return s[E] != '\0' && s[E] != '/';
113 /* fold_comparison */
115 fn14 (void)
117 return (!!i ? : (u *= E / 0)) >= (u = E);
120 /* fold_mult_zconjz */
121 _Complex int
122 fn15 (_Complex volatile int *z)
124 return *z * ~*z;