| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fdump-tree-forwprop2-details -Wno-shift-count-negative" } */ |
| 3 |
|
| 4 |
int ctz_ice1 (int x) |
| 5 |
{ |
| 6 |
static const char table[32] = |
| 7 |
{ |
| 8 |
0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, |
| 9 |
31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 |
| 10 |
}; |
| 11 |
|
| 12 |
return table[((int)((x & -x) * -0x077CB531)) >> 27]; |
| 13 |
} |
| 14 |
|
| 15 |
int ctz_ice2 (unsigned x) |
| 16 |
{ |
| 17 |
static const char table[32] = |
| 18 |
{ |
| 19 |
0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, |
| 20 |
31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 |
| 21 |
}; |
| 22 |
|
| 23 |
return table[((unsigned)((x & -x) * 0x077CB531U)) >> -27]; |
| 24 |
} |
| 25 |
|
| 26 |
// This should never match |
| 27 |
int ctz_fail (unsigned x) |
| 28 |
{ |
| 29 |
static const unsigned short int table[32] = |
| 30 |
u"\x0100\x021c\x0e1d\x0318\x161e\x0f14\x1119\x0804\x1b1f\x170d\x1315\x0710\x0c1a\x0612\x050b\x090a"; |
| 31 |
|
| 32 |
return table[((x & -x) * 0x077CB531) >> 27]; |
| 33 |
} |
| 34 |
|
| 35 |
/* { dg-final { scan-tree-dump-not {= \.CTZ} "forwprop2" } } */ |