2014-04-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / bmi2-mulx32-1.c
blob5e602878138eb8657ddf70875ce42fbede550386
1 /* { dg-do run { target { bmi2 && { ia32 } } } } */
2 /* { dg-options "-mbmi2 -O2" } */
4 #include "bmi2-check.h"
6 __attribute__((noinline))
7 unsigned long long
8 calc_mul_u32 (unsigned volatile a, unsigned b)
10 unsigned long long res = 0;
11 int i;
12 for (i = 0; i < b; ++i)
13 res += a;
15 return res;
18 __attribute__((noinline, regparm (2)))
19 unsigned long long
20 gen_mulx (unsigned a, unsigned b)
22 unsigned long long res;
24 res = (unsigned long long)a * b;
26 return res;
29 static void
30 bmi2_test ()
32 unsigned i;
33 unsigned a = 0xce7ace0;
34 unsigned b = 0xfacefff;
35 unsigned long long res, res_ref;
37 for (i = 0; i < 5; ++i) {
38 a = a * (i + 1);
39 b = b / (i + 1);
41 res_ref = calc_mul_u32 (a, b);
42 res = gen_mulx (a, b);
44 if (res != res_ref)
45 abort();