2015-12-10 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / bmi2-rorx32-1.c
blobd7f6f3b62db23073635c9851d99850db65347e0a
1 /* { dg-do run { target { bmi2 } } } */
2 /* { dg-options "-mbmi2 -O2 -dp" } */
4 #include "bmi2-check.h"
6 __attribute__((noinline))
7 unsigned
8 calc_rorx_u32 (unsigned a, int l)
10 unsigned volatile res = a;
11 int i;
12 for (i = 0; i < l; ++i)
13 res = (res >> 1) | ((res & 1) << 31);
15 return res;
18 #define SHIFT_VAL 0x0e
20 static void
21 bmi2_test ()
23 unsigned i;
24 unsigned src = 0xce7ace0;
25 unsigned res, res_ref;
27 for (i = 0; i < 5; ++i) {
28 src = src * (i + 1);
30 res_ref = calc_rorx_u32 (src, SHIFT_VAL);
31 res = (src >> SHIFT_VAL) | (src << (32 - SHIFT_VAL));
33 if (res != res_ref)
34 abort();