Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.c-torture / execute / 20111227-2.c
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-options "-fdump-rtl-ree -O" } */
4 extern void abort (void);
5
6 unsigned short s;
7 unsigned int i;
8 unsigned long l;
9 unsigned char v = -1;
10
11 void __attribute__((noinline,noclone))
12 bar (int t)
13 {
14   if (t == 2 && s != 0xff)
15     abort ();
16   if (t == 1 && i != 0xff)
17     abort ();
18   if (t == 0 && l != 0xff)
19     abort ();
20 }
21
22 void __attribute__((noinline,noclone))
23 foo (unsigned char *a, int t)
24 {
25   unsigned char r = v;
26
27   if (t == 2)
28     s = (unsigned short) r;
29   else if (t == 1)
30     i = (unsigned int) r;
31   else if (t == 0)
32     l = (unsigned long) r;
33   bar (t);
34 }
35
36 int main(void)
37 {
38   foo (&v, 0);
39   foo (&v, 1);
40   foo (&v, 2);
41   return 0;
42 }
43 /* { dg-final { scan-rtl-dump "Elimination opportunities = 3 realized = 3" "ree" } }  */
44 /* { dg-final { cleanup-rtl-dump "ree" } }  */