Debian Codegraph @

gcc/testsuite/gcc.dg/torture/pr117363-1.c

raw
1 /* { dg-do run } */
2 /* { dg-additional-options "-fgimple" } */
3
4 /* PR tree-optimization/117363 */
5
6 /* a != 0 ? (signed)(((unsigned)a) - 1) : 0
7 Should not be transformed into doing the
8 plus in a signed type which could cause an overflow.` */
9
10 __attribute__((noinline))
11 signed __GIMPLE ()
12 test2 (int n)
13 {
14 unsigned t;
15 _Bool _4;
16 if (n_1(D) > 0) goto unreachable;
17 else goto normal;
18 normal:
19 t_2 = (unsigned)n_1(D);
20 t_3 = t_2 - 1u;
21 n_5 = (signed) t_3;
22 _4 = n_1(D) != 0;
23 n_6 = _4 ? n_5 : 0;
24 if (n_6 > 0) goto return1;
25 else goto trap;
26
27 return1:
28 return n_6;
29
30 unreachable:
31 __builtin_unreachable();
32
33 trap:
34 __builtin_trap ();
35 }
36
37 int main()
38 {
39 unsigned t = -__INT_MAX__ - 1;
40 test2(t);
41 }