aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/pr88753.c
blob: eaefc38962ffd18fcdfcdc5048ca4e7bc4ce0a8b (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* PR tree-optimization/88753 */
/* { dg-options "-O2 -fdump-tree-switchconv" } */
/* { dg-do run { target nonpic } } */

typedef unsigned short int uint16_t;
typedef unsigned char uint8_t;

uint16_t length;
uint16_t enc_method_global;

uint8_t
__attribute__((noipa))
_zip_buffer_get_8(int buffer)
{
  return buffer;
}

  int
  __attribute__((noipa))
foo(int v)
{
  uint16_t enc_method;
  switch (_zip_buffer_get_8(v)) {
    case 1:
      enc_method = 0x0101;
      break;
    case 2:
      enc_method = 0x0102;
      break;
    case 3:
      enc_method = 0x0103;
      break;
    default:
      __builtin_abort ();
  }

  enc_method_global = enc_method;
}

int main(int argc, char **argv)
{
  foo (1);
  if (enc_method_global != 0x0101)
    __builtin_abort ();

  foo (2);
  if (enc_method_global != 0x0102)
    __builtin_abort ();

  foo (3);
  if (enc_method_global != 0x0103)
    __builtin_abort ();

  return 0;
}

/* { dg-final { scan-tree-dump-times "Linear transformation with A = 1 and B = 256" 1 "switchconv" } } */