2018-05-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / 20111227-2.c
blob2de29b91be1824f758929294648d5a7c855e26e3
1 /* Testcase derived from 20111227-1.c to ensure that REE is combining
2 redundant zero extends with zero extend to wider mode. */
3 /* { dg-do compile { target i?86-*-* x86_64-*-* } } */
4 /* { dg-options "-fdump-rtl-ree -O -free" } */
6 extern void abort (void);
8 unsigned short s;
9 unsigned int i;
10 unsigned long l;
11 unsigned char v = -1;
13 void __attribute__((noinline,noclone))
14 bar (int t)
16 if (t == 2 && s != 0xff)
17 abort ();
18 if (t == 1 && i != 0xff)
19 abort ();
20 if (t == 0 && l != 0xff)
21 abort ();
24 void __attribute__((noinline,noclone))
25 foo (unsigned char *a, int t)
27 unsigned char r = v;
29 if (t == 2)
30 s = (unsigned short) r;
31 else if (t == 1)
32 i = (unsigned int) r;
33 else if (t == 0)
34 l = (unsigned long) r;
35 bar (t);
38 int main(void)
40 foo (&v, 0);
41 foo (&v, 1);
42 foo (&v, 2);
43 return 0;
45 /* { dg-final { scan-rtl-dump "Elimination opportunities = 3 realized = 3" "ree" } } */