| 1 |
/* PR tree-optimization/61839. */ |
| 2 |
/* { dg-do run } */ |
| 3 |
/* { dg-options "-O2 -fdisable-tree-evrp -fdisable-tree-ethread -fdisable-tree-threadfull1 -fdump-tree-vrp1 -fdump-tree-optimized" } */ |
| 4 |
/* { dg-require-effective-target int32plus } */ |
| 5 |
|
| 6 |
__attribute__ ((noinline)) |
| 7 |
int foo () |
| 8 |
{ |
| 9 |
int a = -1; |
| 10 |
volatile unsigned b = 1U; |
| 11 |
int c = 1; |
| 12 |
c = (a + 972195718) >> (1LU <= b); |
| 13 |
if (c == 486097858) |
| 14 |
; |
| 15 |
else |
| 16 |
__builtin_abort (); |
| 17 |
return 0; |
| 18 |
} |
| 19 |
|
| 20 |
__attribute__ ((noinline)) |
| 21 |
int bar () |
| 22 |
{ |
| 23 |
int a = -1; |
| 24 |
volatile unsigned b = 1U; |
| 25 |
int c = 1; |
| 26 |
c = (a + 972195718) >> (b ? 2 : 3); |
| 27 |
if (c == 243048929) |
| 28 |
; |
| 29 |
else |
| 30 |
__builtin_abort (); |
| 31 |
return 0; |
| 32 |
} |
| 33 |
|
| 34 |
int main () |
| 35 |
{ |
| 36 |
foo (); |
| 37 |
bar (); |
| 38 |
} |
| 39 |
|
| 40 |
/* Scan for c = 972195717) >> [0, 1] in function foo. */ |
| 41 |
/* { dg-final { scan-tree-dump-times "972195717 : 486097858" 1 "vrp1" } } */ |
| 42 |
|
| 43 |
/* Previously we were checking for two ?: with constant PHI arguments, |
| 44 |
but now we collapse them into one. */ |
| 45 |
/* Scan for c = 972195717) >> [2, 3] in function bar. */ |
| 46 |
/* { dg-final { scan-tree-dump-times "243048929 : 121524464" 1 "vrp1" } } */ |
| 47 |
|
| 48 |
/* { dg-final { scan-tree-dump-times "486097858" 0 "optimized" } } */ |