| 1 |
/* PR tree-optimization/116024 */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-O1 -fdump-tree-forwprop1-details" } */ |
| 4 |
|
| 5 |
#include <stdint.h> |
| 6 |
#include <limits.h> |
| 7 |
|
| 8 |
uint32_t f(void); |
| 9 |
|
| 10 |
int32_t i1(void) |
| 11 |
{ |
| 12 |
int32_t l = 10 - (int32_t)f(); |
| 13 |
return l <= 9; // f() > 0 |
| 14 |
} |
| 15 |
|
| 16 |
int32_t i1a(void) |
| 17 |
{ |
| 18 |
int32_t l = 20 - (int32_t)f(); |
| 19 |
return l <= INT32_MIN; // return 0 |
| 20 |
} |
| 21 |
|
| 22 |
int32_t i1b(void) |
| 23 |
{ |
| 24 |
int32_t l = 30 - (int32_t)f(); |
| 25 |
return l <= INT32_MIN + 31; // f() == INT32_MAX |
| 26 |
} |
| 27 |
|
| 28 |
int32_t i1c(void) |
| 29 |
{ |
| 30 |
int32_t l = INT32_MAX - 40 - (int32_t)f(); |
| 31 |
return l <= -38; // f() > INT32_MAX - 3 |
| 32 |
} |
| 33 |
|
| 34 |
int32_t i1d(void) |
| 35 |
{ |
| 36 |
int32_t l = INT32_MAX - 50 - (int32_t)f(); |
| 37 |
return l <= INT32_MAX - 1; // f() != -50 |
| 38 |
} |
| 39 |
|
| 40 |
int32_t i1e(void) |
| 41 |
{ |
| 42 |
int32_t l = INT32_MAX - 60 - (int32_t)f(); |
| 43 |
return l != INT32_MAX - 90; // f() != 30 |
| 44 |
} |
| 45 |
|
| 46 |
int32_t i1f(void) |
| 47 |
{ |
| 48 |
int32_t l = INT32_MIN + 70 - (int32_t)f(); |
| 49 |
return l <= INT32_MAX - 2; // return 0 |
| 50 |
} |
| 51 |
|
| 52 |
int32_t i1g(void) |
| 53 |
{ |
| 54 |
int32_t l = INT32_MAX/2 + 30 - (int32_t)f(); |
| 55 |
return l <= INT32_MIN/2 - 30; // return 1 |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
/* { dg-final { scan-tree-dump-times "Removing dead stmt:.*?- _" 5 "forwprop1" } } */ |
| 60 |
/* { dg-final { scan-tree-dump-times "return 0" 2 "forwprop1" } } */ |
| 61 |
/* { dg-final { scan-tree-dump-times "return 1" 1 "forwprop1" } } */ |
| 62 |
/* { dg-final { scan-tree-dump-times "gimple_simplified to.* > 0" 1 "forwprop1" } } */ |
| 63 |
/* { dg-final { scan-tree-dump-times "gimple_simplified to.* == 2147483647" 1 "forwprop1" } } */ |
| 64 |
/* { dg-final { scan-tree-dump-times "gimple_simplified to.* > 2147483644" 1 "forwprop1" } } */ |
| 65 |
/* { dg-final { scan-tree-dump-times "gimple_simplified to.* != 4294967246" 1 "forwprop1" } } */ |
| 66 |
/* { dg-final { scan-tree-dump-times "gimple_simplified to.* != 30" 1 "forwprop1" } } */ |