| 1 |
/* Test that we can remove the conditional move due to CLZ |
| 2 |
being defined at zero. */ |
| 3 |
|
| 4 |
/* { dg-do compile } */ |
| 5 |
/* { dg-require-effective-target arm_arch_v6t2_ok } */ |
| 6 |
/* { dg-options "-O2" } */ |
| 7 |
/* { dg-add-options arm_arch_v6t2 } */ |
| 8 |
|
| 9 |
int |
| 10 |
fooctz (int i) |
| 11 |
{ |
| 12 |
return (i == 0) ? 32 : __builtin_ctz (i); |
| 13 |
} |
| 14 |
|
| 15 |
int |
| 16 |
fooctz2 (int i) |
| 17 |
{ |
| 18 |
return (i != 0) ? __builtin_ctz (i) : 32; |
| 19 |
} |
| 20 |
|
| 21 |
unsigned int |
| 22 |
fooctz3 (unsigned int i) |
| 23 |
{ |
| 24 |
return (i > 0) ? __builtin_ctz (i) : 32; |
| 25 |
} |
| 26 |
|
| 27 |
/* { dg-final { scan-assembler-times "rbit\t*" 3 } } */ |
| 28 |
|
| 29 |
int |
| 30 |
fooclz (int i) |
| 31 |
{ |
| 32 |
return (i == 0) ? 32 : __builtin_clz (i); |
| 33 |
} |
| 34 |
|
| 35 |
int |
| 36 |
fooclz2 (int i) |
| 37 |
{ |
| 38 |
return (i != 0) ? __builtin_clz (i) : 32; |
| 39 |
} |
| 40 |
|
| 41 |
unsigned int |
| 42 |
fooclz3 (unsigned int i) |
| 43 |
{ |
| 44 |
return (i > 0) ? __builtin_clz (i) : 32; |
| 45 |
} |
| 46 |
|
| 47 |
/* { dg-final { scan-assembler-times "clz\t" 6 } } */ |
| 48 |
/* { dg-final { scan-assembler-not "cmp\t.*0" } } */ |