aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/pr84436-1.c
blob: a045b44c2b944c52d03f6c0ca31edbdb6a2a64b7 (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
/* PR tree-optimization/84436 */
/* { dg-options "-O2 -fdump-tree-switchconv -fdump-tree-optimized" } */
/* { dg-do run } */

int
__attribute__ ((noipa))
foo (int how)
{
  switch (how) {
    case 2: how = 205; break; /* how = 100 * index + 5 */
    case 3: how = 305; break;
    case 4: how = 405; break;
    case 5: how = 505; break;
    case 6: how = 605; break;
  }
  return how;
}

int main()
{
  if (foo (2) != 205)
  __builtin_abort ();

  if (foo (6) != 605)
  __builtin_abort ();

  if (foo (123) != 123)
  __builtin_abort ();

  return 0;
}


/* { dg-final { scan-tree-dump-times "100 \\*" 1 "switchconv" } } */
/* { dg-final { scan-tree-dump-times ".* \\+ 5" 1 "switchconv" } } */
/* { dg-final { scan-tree-dump-not "switch" "optimized" } } */