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