[3/3][RTL ifcvt] PR middle-end/37780: Conditional expression with __builtin_clz(...
[official-gcc.git] / gcc / testsuite / gcc.target / aarch64 / pr37780_1.c
blob97027e7479cfe284322249f8a4edc7d3da8ff644
1 /* Test that we can remove the conditional move due to CLZ
2 and CTZ being defined at zero. */
4 /* { dg-do compile } */
5 /* { dg-options "-O2" } */
7 int
8 fooctz (int i)
10 return (i == 0) ? 32 : __builtin_ctz (i);
13 int
14 fooctz2 (int i)
16 return (i != 0) ? __builtin_ctz (i) : 32;
19 unsigned int
20 fooctz3 (unsigned int i)
22 return (i > 0) ? __builtin_ctz (i) : 32;
25 /* { dg-final { scan-assembler-times "rbit\t*" 3 } } */
27 int
28 fooclz (int i)
30 return (i == 0) ? 32 : __builtin_clz (i);
33 int
34 fooclz2 (int i)
36 return (i != 0) ? __builtin_clz (i) : 32;
39 unsigned int
40 fooclz3 (unsigned int i)
42 return (i > 0) ? __builtin_clz (i) : 32;
45 /* { dg-final { scan-assembler-times "clz\t" 6 } } */
46 /* { dg-final { scan-assembler-not "cmp\t.*0" } } */