gcc/testsuite/gcc.target/i386/pr101175.c
raw| 1 | /* { dg-do run } */ |
| 2 | /* { dg-options "-O2 -mlzcnt" } */ |
| 3 | /* { dg-require-effective-target lzcnt } */ |
| 4 | |
| 5 | #include "lzcnt-check.h" |
| 6 | |
| 7 | static int |
| 8 | foo (unsigned int v) |
| 9 | { |
| 10 | return v ? __builtin_clz (v) : 32; |
| 11 | } |
| 12 | |
| 13 | /* returns -1 if x == 0 */ |
| 14 | int |
| 15 | __attribute__ ((noinline, noclone)) |
| 16 | bar (unsigned int x) |
| 17 | { |
| 18 | return 31 - foo (x); |
| 19 | } |
| 20 | |
| 21 | static void |
| 22 | lzcnt_test () |
| 23 | { |
| 24 | int r = bar (0); |
| 25 | |
| 26 | if (r != -1) |
| 27 | abort (); |
| 28 | } |