| 1 |
/* PR tree-optimization/98304 */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-O2 -fdump-tree-optimized" } */ |
| 4 |
|
| 5 |
/* Signed test function. */ |
| 6 |
__attribute__((noipa)) int foo(int n) { |
| 7 |
return n - (((n > 63) ? n : 63) & -64); |
| 8 |
} |
| 9 |
|
| 10 |
/* Unsigned test function. */ |
| 11 |
__attribute__((noipa)) unsigned int bar(unsigned int n) { |
| 12 |
return n - (((n > 63) ? n : 63) & -64); |
| 13 |
} |
| 14 |
|
| 15 |
/* Different power of 2. */ |
| 16 |
__attribute__((noipa)) int goo(int n) { |
| 17 |
return n - (((n > 31) ? n : 31) & -32); |
| 18 |
} |
| 19 |
|
| 20 |
/* Commutative property (should be identical to foo) */ |
| 21 |
__attribute__((noipa)) int baz(int n) { |
| 22 |
return n - (((64 > n) ? 63 : n) & -64); |
| 23 |
} |
| 24 |
|
| 25 |
/* < instead of >. */ |
| 26 |
__attribute__((noipa)) int fred(int n) { |
| 27 |
return n - (((63 < n) ? n : 63) & -64); |
| 28 |
} |
| 29 |
|
| 30 |
/* Constant is not a power of 2 so should not simplify. */ |
| 31 |
__attribute__((noipa)) int qux(int n) { |
| 32 |
return n - (((n > 62) ? n : 62) & -63); |
| 33 |
} |
| 34 |
|
| 35 |
/* Constant is not a power of 2 so should not simplify. */ |
| 36 |
__attribute__((noipa)) unsigned int quux(unsigned int n) { |
| 37 |
return n - (((n > 62) ? n : 62) & -63); |
| 38 |
} |
| 39 |
|
| 40 |
/* Constant is a variable so should not simplify. */ |
| 41 |
__attribute__((noipa)) int waldo(int n, int x) { |
| 42 |
return n - (((n > 63) ? n : 63) & x); |
| 43 |
} |
| 44 |
|
| 45 |
/* Difference between constants is not -1. */ |
| 46 |
__attribute__((noipa)) int corge(int n) { |
| 47 |
return n - (((n > 1) ? n : 1) & -64); |
| 48 |
} |
| 49 |
|
| 50 |
/* Difference between constants is not -1. */ |
| 51 |
__attribute__((noipa)) unsigned int thud(unsigned int n) |
| 52 |
{ |
| 53 |
return n - (((n > 1) ? n : 1) & -64); |
| 54 |
} |
| 55 |
|
| 56 |
/* { dg-final { scan-tree-dump-times " - " 5 "optimized" } } */ |
| 57 |
/* { dg-final { scan-tree-dump-times " <= " 4 "optimized" } } */ |