2018-11-28 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / 20111227-3.c
blobf1bd35911ab83be7bd3c8790e215217170c31b50
1 /* Testcase derived from 20111227-1.c to ensure that REE is combining
2 redundant sign extends with sign 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 signed short s;
9 signed int i;
10 signed long l;
11 signed char v = -1;
13 void __attribute__((noinline,noclone))
14 bar (int t)
16 if (t == 2 && s != -1)
17 abort ();
18 if (t == 1 && i != -1)
19 abort ();
20 if (t == 0 && l != -1)
21 abort ();
24 void __attribute__((noinline,noclone))
25 foo (signed char *a, int t)
27 signed char r = v;
29 if (t == 2)
30 s = (signed short) r;
31 else if (t == 1)
32 i = (signed int) r;
33 else if (t == 0)
34 l = (signed 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" } } */