| 1 |
/* { dg-do compile { target { ! riscv_abi_e } } } */ |
| 2 |
/* { dg-options "-O2 -fdump-tree-forwprop2-details" } */ |
| 3 |
/* { dg-additional-options "-mbmi" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } */ |
| 4 |
/* { dg-additional-options "-march=rv64gc_zbb" { target { rv64 } } } */ |
| 5 |
/* { dg-additional-options "-march=rv32gc_zbb" { target { rv32 } } } */ |
| 6 |
/* { dg-require-effective-target int32plus } */ |
| 7 |
|
| 8 |
static const unsigned long long magic = 0x03f08c5392f756cdULL; |
| 9 |
|
| 10 |
static const char table[128] = { |
| 11 |
0, 1, 12, 2, 13, 22, 17, 3, |
| 12 |
14, 33, 23, 36, 18, 58, 28, 4, |
| 13 |
62, 15, 34, 26, 24, 48, 50, 37, |
| 14 |
19, 55, 59, 52, 29, 44, 39, 5, |
| 15 |
63, 11, 21, 16, 32, 35, 57, 27, |
| 16 |
61, 25, 47, 49, 54, 51, 43, 38, |
| 17 |
10, 20, 31, 56, 60, 46, 53, 42, |
| 18 |
9, 30, 45, 41, 8, 40, 7, 6, |
| 19 |
1, 2, 3, 4, 5, 6, 7, 8, |
| 20 |
9, 10, 11, 12, 13, 14, 15, 16, |
| 21 |
17, 18, 19, 20, 21, 22, 23, 24, |
| 22 |
25, 26, 27, 28, 29, 30, 31, 32, |
| 23 |
33, 34, 35, 36, 37, 38, 39, 40, |
| 24 |
41, 42, 43, 44, 45, 46, 47, 48, |
| 25 |
49, 50, 51, 52, 53, 54, 55, 56, |
| 26 |
57, 58, 59, 60, 61, 62, 63, 64 |
| 27 |
}; |
| 28 |
|
| 29 |
int ctz4 (unsigned long long x) |
| 30 |
{ |
| 31 |
unsigned long long lsb = x & -x; |
| 32 |
return table[(lsb * magic) >> 58]; |
| 33 |
} |
| 34 |
|
| 35 |
/* { dg-final { scan-tree-dump {= \.CTZ} "forwprop2" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } } */ |
| 36 |
/* { dg-final { scan-tree-dump {= \.CTZ} "forwprop2" { target aarch64*-*-* } } } */ |
| 37 |
/* { dg-final { scan-tree-dump {= \.CTZ} "forwprop2" { target { rv64 } } } } */ |
| 38 |
/* { dg-final { scan-tree-dump {= \.CTZ} "forwprop2" { target { rv32 } } } } */ |
| 39 |
/* { dg-final { scan-tree-dump {= \.CTZ} "forwprop2" { target { loongarch64*-*-* } } } } */ |