2 /* { dg-options "-O2 -fwrapv" } */
4 /* PR tree-optimization/21029
6 f() used to get optimized to an infinite loop by tree-vrp, because
7 j is assumed to be non-negative. Even though the conversion from
8 unsigned to signed has unspecified results if the expression value
9 is not representable in the signed type, the compiler itself (e.g.,
10 the Ada front end) depends on wrap-around behavior. */
12 unsigned int f(void) {
13 unsigned char i
= 123;
17 if ((j
= (signed char) i
) < 0)
26 /* Now let's torture it a bit further. Narrowing conversions need
29 unsigned int f1 (void) {
30 unsigned short i
= 123;
34 if ((j
= (signed char) i
) < 0)
43 /* And so do widening conversions. */
45 unsigned int f2 (void) {
46 unsigned char i
= 123;
50 if ((j
= (signed short) (signed char) i
) < 0)
59 /* Check same-sign truncations with an increment that turns into
62 unsigned int f3 (void) {
67 if ((j
= (signed char) i
) < 0)
76 /* Check that the truncation above doesn't confuse the result of the
77 test after a widening conversion. */
79 unsigned int f4 (void) {
80 signed short i
= -123;
84 if ((j
= (signed int) (signed char) i
) > 0)
93 /* Even if we omit the widening truncation, the narrowing truncation
94 is implementation-defined. */
96 unsigned int f5 (void) {
101 if ((j
= (signed char) i
) > 0)