| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fdump-tree-reassoc1 -fno-ipa-icf" } */ |
| 3 |
|
| 4 |
/* We want to make sure that we reassociate in a way that has the |
| 5 |
constant last. With the constant last, it's more likely to result |
| 6 |
in a bitfield test on targets with such capabilities. */ |
| 7 |
|
| 8 |
extern void boo (); |
| 9 |
|
| 10 |
int b2b_uc (unsigned char u, unsigned char w) |
| 11 |
{ |
| 12 |
if ((u & w) & 0x20) |
| 13 |
boo (); |
| 14 |
} |
| 15 |
|
| 16 |
int b2b_us (unsigned short u, unsigned short w) |
| 17 |
{ |
| 18 |
if ((u & w) & 0x20) |
| 19 |
boo (); |
| 20 |
} |
| 21 |
|
| 22 |
int b2b_ui (unsigned int u, unsigned int w) |
| 23 |
{ |
| 24 |
if ((u & w) & 0x20) |
| 25 |
boo (); |
| 26 |
} |
| 27 |
int b2b_ul (unsigned long u, unsigned long w) |
| 28 |
{ |
| 29 |
if ((u & w) & 0x20) |
| 30 |
boo (); |
| 31 |
} |
| 32 |
int b2b_ull (unsigned long long u, unsigned long long w) |
| 33 |
{ |
| 34 |
if ((u & w) & 0x20) |
| 35 |
boo (); |
| 36 |
} |
| 37 |
|
| 38 |
int b2b_sc (signed char u, signed char w) |
| 39 |
{ |
| 40 |
if ((u & w) & 0x20) |
| 41 |
boo (); |
| 42 |
} |
| 43 |
|
| 44 |
int b2b_ss (signed short u, signed short w) |
| 45 |
{ |
| 46 |
if ((u & w) & 0x20) |
| 47 |
boo (); |
| 48 |
} |
| 49 |
|
| 50 |
int b2b_si (signed int u, signed int w) |
| 51 |
{ |
| 52 |
if ((u & w) & 0x20) |
| 53 |
boo (); |
| 54 |
} |
| 55 |
int b2b_sl (signed long u, signed long w) |
| 56 |
{ |
| 57 |
if ((u & w) & 0x20) |
| 58 |
boo (); |
| 59 |
} |
| 60 |
int b2b_sll (signed long long u, signed long long w) |
| 61 |
{ |
| 62 |
if ((u & w) & 0x20) |
| 63 |
boo (); |
| 64 |
} |
| 65 |
|
| 66 |
/* The AND of U & W should go into a temporary, when is then ANDed |
| 67 |
with the constant. |
| 68 |
|
| 69 |
First verify that we have the right number of ANDs between U and W. */ |
| 70 |
/* { dg-final { scan-tree-dump-times "\[uw\]_\[0-9\]+.D. \& \[uw\]_\[0-9\]+.D.;" 10 "reassoc1"} } */ |
| 71 |
|
| 72 |
/* Then verify that we have the right number of ANDS between a temporary |
| 73 |
and the constant. */ |
| 74 |
/* { dg-final { scan-tree-dump-times "_\[0-9]+ \& 32;" 10 "reassoc1"} } */ |
| 75 |
|
| 76 |
/* Each function has one AND. It will have either a second AND or TEST. So |
| 77 |
we can count the number of AND and TEST instructions. They must be 2X |
| 78 |
the number of test functions in this file. */ |
| 79 |
/* { dg-final { scan-assembler-times "and|test" 20 { target { i?86-*-* x86_64-*-*} } } } */ |
| 80 |
|
| 81 |
/* Similarly on the m68k. The code for the long long tests is suboptimal, |
| 82 |
which catch via the second pattern and xfail. */ |
| 83 |
/* { dg-final { scan-assembler-times "and|btst" 20 { target { m68k-*-* } } } } */ |
| 84 |
/* { dg-final { scan-assembler-not "or" { target { m68k-*-* } xfail { *-*-* } } } } */ |
| 85 |
|