| 1 |
/* PR tree-optimization/92860. */ |
| 2 |
/* Testcase derived from 20111227-1.c to ensure that REE is combining |
| 3 |
redundant zero extends with zero extend to wider mode. */ |
| 4 |
/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ |
| 5 |
/* { dg-options "-fdump-rtl-ree" } */ |
| 6 |
|
| 7 |
extern void abort (void); |
| 8 |
|
| 9 |
unsigned short s; |
| 10 |
unsigned int i; |
| 11 |
unsigned long l; |
| 12 |
unsigned char v = -1; |
| 13 |
|
| 14 |
void |
| 15 |
__attribute__ ((optimize("-O2"))) |
| 16 |
baz() |
| 17 |
{ |
| 18 |
} |
| 19 |
|
| 20 |
void __attribute__((noinline,noclone)) |
| 21 |
bar (int t) |
| 22 |
{ |
| 23 |
if (t == 2 && s != 0xff) |
| 24 |
abort (); |
| 25 |
if (t == 1 && i != 0xff) |
| 26 |
abort (); |
| 27 |
if (t == 0 && l != 0xff) |
| 28 |
abort (); |
| 29 |
} |
| 30 |
|
| 31 |
void __attribute__((noinline,noclone)) |
| 32 |
foo (unsigned char *a, int t) |
| 33 |
{ |
| 34 |
unsigned char r = v; |
| 35 |
|
| 36 |
if (t == 2) |
| 37 |
s = (unsigned short) r; |
| 38 |
else if (t == 1) |
| 39 |
i = (unsigned int) r; |
| 40 |
else if (t == 0) |
| 41 |
l = (unsigned long) r; |
| 42 |
bar (t); |
| 43 |
} |
| 44 |
|
| 45 |
int main(void) |
| 46 |
{ |
| 47 |
foo (&v, 0); |
| 48 |
foo (&v, 1); |
| 49 |
foo (&v, 2); |
| 50 |
return 0; |
| 51 |
} |
| 52 |
|
| 53 |
/* { dg-final { scan-rtl-dump-not "Elimination opportunities" "ree" } } */ |