[3/3][RTL ifcvt] PR middle-end/37780: Conditional expression with __builtin_clz(...
[official-gcc.git] / gcc / testsuite / gcc.target / arm / pr37780_1.c
blobb954fe5ceb89690feaa1098d0471b518bcbe0631
1 /* Test that we can remove the conditional move due to CLZ
2 being defined at zero. */
4 /* { dg-do compile } */
5 /* { dg-require-effective-target arm_arch_v5_ok } */
6 /* { dg-options "-O2" } */
8 int
9 fooctz (int i)
11 return (i == 0) ? 32 : __builtin_ctz (i);
14 int
15 fooctz2 (int i)
17 return (i != 0) ? __builtin_ctz (i) : 32;
20 unsigned int
21 fooctz3 (unsigned int i)
23 return (i > 0) ? __builtin_ctz (i) : 32;
26 /* { dg-final { scan-assembler-times "rbit\t*" 3 } } */
28 int
29 fooclz (int i)
31 return (i == 0) ? 32 : __builtin_clz (i);
34 int
35 fooclz2 (int i)
37 return (i != 0) ? __builtin_clz (i) : 32;
40 unsigned int
41 fooclz3 (unsigned int i)
43 return (i > 0) ? __builtin_clz (i) : 32;
46 /* { dg-final { scan-assembler-times "clz\t" 6 } } */
47 /* { dg-final { scan-assembler-not "cmp\t.*0" } } */