aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/pr101175.c
blob: ed7a08110a55ce819fd0bf41756df4b950894d61 (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
/* { dg-do run } */
/* { dg-options "-O2 -mlzcnt" } */
/* { dg-require-effective-target lzcnt } */

#include "lzcnt-check.h"

static int
foo (unsigned int v)
{
  return v ? __builtin_clz (v) : 32;
}

/* returns -1 if x == 0 */
int
__attribute__ ((noinline, noclone))
bar (unsigned int x)
{
  return 31 - foo (x);
}

static void
lzcnt_test ()
{
  int r = bar (0);

  if (r != -1)
    abort ();
}