summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/aarch64/pr37780_1.c
blob: 97027e7479cfe284322249f8a4edc7d3da8ff644 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* Test that we can remove the conditional move due to CLZ
   and CTZ being defined at zero.  */

/* { dg-do compile } */
/* { dg-options "-O2" } */

int
fooctz (int i)
{
  return (i == 0) ? 32 : __builtin_ctz (i);
}

int
fooctz2 (int i)
{
  return (i != 0) ? __builtin_ctz (i) : 32;
}

unsigned int
fooctz3 (unsigned int i)
{
  return (i > 0) ?  __builtin_ctz (i) : 32;
}

/* { dg-final { scan-assembler-times "rbit\t*" 3 } } */

int
fooclz (int i)
{
  return (i == 0) ? 32 : __builtin_clz (i);
}

int
fooclz2 (int i)
{
  return (i != 0) ? __builtin_clz (i) : 32;
}

unsigned int
fooclz3 (unsigned int i)
{
  return (i > 0) ? __builtin_clz (i) : 32;
}

/* { dg-final { scan-assembler-times "clz\t" 6 } } */
/* { dg-final { scan-assembler-not "cmp\t.*0" } } */