| 1 |
/* PR tree-optimization/102232 */ |
| 2 |
/* { dg-do run } */ |
| 3 |
/* { dg-options "-O -fdump-tree-optimized" } */ |
| 4 |
/* { dg-require-effective-target int32plus } */ |
| 5 |
|
| 6 |
int __attribute__ ((noipa)) foo (int a, int b) |
| 7 |
{ |
| 8 |
return b * (1 + a / b) - a; |
| 9 |
} |
| 10 |
|
| 11 |
int |
| 12 |
main (void) |
| 13 |
{ |
| 14 |
// few randomly generated test cases |
| 15 |
if (foo (71856034, 238) != 212) |
| 16 |
{ |
| 17 |
__builtin_abort (); |
| 18 |
} |
| 19 |
if (foo (71856034, 10909) != 1549) |
| 20 |
{ |
| 21 |
__builtin_abort (); |
| 22 |
} |
| 23 |
if (foo (20350, 1744) != 578) |
| 24 |
{ |
| 25 |
__builtin_abort (); |
| 26 |
} |
| 27 |
if (foo (444813, 88563) != 86565) |
| 28 |
{ |
| 29 |
__builtin_abort (); |
| 30 |
} |
| 31 |
if (foo (112237, 63004) != 13771) |
| 32 |
{ |
| 33 |
__builtin_abort (); |
| 34 |
} |
| 35 |
if (foo (68268386, 787116) != 210706) |
| 36 |
{ |
| 37 |
__builtin_abort (); |
| 38 |
} |
| 39 |
if (foo (-444813, 88563) != 90561) |
| 40 |
{ |
| 41 |
__builtin_abort (); |
| 42 |
} |
| 43 |
if (foo (-68268386, 787116) != 1363526) |
| 44 |
{ |
| 45 |
__builtin_abort (); |
| 46 |
} |
| 47 |
|
| 48 |
return 0; |
| 49 |
} |
| 50 |
|
| 51 |
/* Verify that multiplication and division has been removed. */ |
| 52 |
/* { dg-final { scan-tree-dump-not " \\* " "optimized" } } */ |
| 53 |
/* { dg-final { scan-tree-dump-not " / " "optimized" } } */ |