| 1 |
/* PR tree-optimization/116024 */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-O1 -fdump-tree-forwprop1-details -fwrapv" } */ |
| 4 |
|
| 5 |
#include <stdint.h> |
| 6 |
#include <limits.h> |
| 7 |
|
| 8 |
uint32_t f(void); |
| 9 |
|
| 10 |
int32_t i3(void) |
| 11 |
{ |
| 12 |
int32_t l = -10 + (int32_t)f(); |
| 13 |
return l <= INT32_MAX - 10; // f() >= INT32_MIN + 10 |
| 14 |
} |
| 15 |
|
| 16 |
int32_t i3a(void) |
| 17 |
{ |
| 18 |
int32_t l = -20 + (int32_t)f(); |
| 19 |
return l < INT32_MAX - 19; // f() > INT32_MAX + 20 |
| 20 |
} |
| 21 |
|
| 22 |
int32_t i3b(void) |
| 23 |
{ |
| 24 |
int32_t l = 30 + (int32_t)f(); |
| 25 |
return l >= INT32_MIN + 30; // f() <= INT32_MAX - 30 |
| 26 |
} |
| 27 |
|
| 28 |
int32_t i3c(void) |
| 29 |
{ |
| 30 |
int32_t l = 40 + (int32_t)f(); |
| 31 |
return l > INT32_MIN + 39; // f() < INT32_MIN - 40 |
| 32 |
} |
| 33 |
|
| 34 |
/* { dg-final { scan-tree-dump-times "Removing dead stmt:.*? \\+" 4 "forwprop1" } } */ |
| 35 |
/* { dg-final { scan-tree-dump-times "gimple_simplified to.* >= -2147483638" 1 "forwprop1" } } */ |
| 36 |
/* { dg-final { scan-tree-dump-times "gimple_simplified to.* >= -2147483628" 1 "forwprop1" } } */ |
| 37 |
/* { dg-final { scan-tree-dump-times "gimple_simplified to.* <= 2147483617" 1 "forwprop1" } } */ |
| 38 |
/* { dg-final { scan-tree-dump-times "gimple_simplified to.* <= 2147483607" 1 "forwprop1" } } */ |