aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/torture/pr117363-1.c
blob: b8b5bea76f86d5d132271ff872212d64adb7345e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* { dg-do run } */
/* { dg-additional-options "-fgimple" } */

/* PR tree-optimization/117363 */

/* a != 0 ? (signed)(((unsigned)a) - 1) : 0
   Should not be transformed into doing the
   plus in a signed type which could cause an overflow.` */

__attribute__((noinline))
signed __GIMPLE ()
test2 (int n)
{
  unsigned t;
  _Bool _4;
  if (n_1(D) > 0) goto unreachable;
  else goto normal;
normal:
  t_2 = (unsigned)n_1(D);
  t_3 = t_2 - 1u;
  n_5 = (signed) t_3;
  _4 = n_1(D) != 0;
  n_6 = _4 ? n_5 : 0;
  if (n_6 > 0) goto return1;
  else goto trap;

return1:
  return n_6;

unreachable:
  __builtin_unreachable();

trap:
  __builtin_trap ();
}

int main()
{
  unsigned t = -__INT_MAX__ - 1;
  test2(t);
}