PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / pr22236.c
blob1986c2f0cfe8c4f0ccf21b34446a411628851e19
1 /* { dg-do run } */
2 /* { dg-options "-O1 -fno-tree-vrp -fwrapv" } */
4 /* PR tree-optimization/22236
6 Avoid conversion of (signed char) {(uchar)1, +, (uchar)1}_x when
7 it is not possible to prove that the scev does not wrap.
9 In this PR, a sequence 1, 2, ..., 255 has to be converted to
10 signed char, but this would wrap: 1, 2, ..., 127, -128, ... The
11 result should not be a linear scev {(schar)1, +, (schar)1}_x.
12 The conversion should be kept: (schar) {(uchar)1, +, (uchar)1}_x.
15 void abort(void);
17 static inline void
18 foo (signed char a)
20 int b = a - 0x7F;
21 if (b > 1)
22 abort();
25 int main()
27 unsigned char b;
28 for(b = 0; b < 0xFF; b++)
29 foo (b);
31 return 0;