Debian Codegraph @

gcc/testsuite/gcc.target/aarch64/pr37780_1.c

raw
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
8 fooctz (int i)
9 {
10 return (i == 0) ? 32 : __builtin_ctz (i);
11 }
12
13 int
14 fooctz2 (int i)
15 {
16 return (i != 0) ? __builtin_ctz (i) : 32;
17 }
18
19 unsigned int
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
28 fooclz (int i)
29 {
30 return (i == 0) ? 32 : __builtin_clz (i);
31 }
32
33 int
34 fooclz2 (int i)
35 {
36 return (i != 0) ? __builtin_clz (i) : 32;
37 }
38
39 unsigned int
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" } } */