PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / bmi2-mulx32-2.c
blob82c3a4f446e649596d484cc638198cb3d25adc48
1 /* { dg-do run { target { bmi2 && ia32 } } } */
2 /* { dg-options "-mbmi2 -O2" } */
4 #include <x86intrin.h>
6 #include "bmi2-check.h"
8 __attribute__((noinline))
9 unsigned long long
10 calc_mul_u32 (unsigned volatile a, unsigned b)
12 unsigned long long res = 0;
13 int i;
14 for (i = 0; i < b; ++i)
15 res += a;
17 return res;
20 __attribute__((noinline, regparm (2)))
21 unsigned calc_mulx_u32 (unsigned x, unsigned y, unsigned *res_h)
23 return (unsigned) _mulx_u32 (x, y, res_h);
26 static void
27 bmi2_test ()
29 unsigned i;
30 unsigned a = 0xce7ace0;
31 unsigned b = 0xfacefff;
32 unsigned res_l, res_h;
33 unsigned long long res, res_ref;
35 for (i = 0; i < 5; ++i) {
36 a = a * (i + 1);
37 b = b / (i + 1);
39 res_ref = calc_mul_u32 (a, b);
40 res_l = calc_mulx_u32 (a, b, &res_h);
42 res = ((unsigned long long) res_h << 32) | res_l;
44 if (res != res_ref)
45 abort();