2018-03-08 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / bmi2-mulx64-1.c
blob68449466ceb9657000668cc125cca343d4b2eb44
1 /* { dg-do run { target { bmi2 && { ! ia32 } } } } */
2 /* { dg-options "-mbmi2 -O2" } */
4 #include "bmi2-check.h"
6 __attribute__((noinline))
7 unsigned __int128
8 calc_mul_u64 (unsigned long long volatile a, unsigned long long b)
10 unsigned __int128 res = 0;
11 int i;
12 for (i = 0; i < b; ++i)
13 res += (unsigned __int128) a;
15 return res;
18 static void
19 bmi2_test ()
21 unsigned i;
22 unsigned long long a = 0xce7ace0ce7ace0;
23 unsigned long long b = 0xface;
24 unsigned __int128 res, res_ref;
26 for (i=0; i<5; ++i) {
27 a = a * (i + 1);
28 b = b / (i + 1);
30 res_ref = calc_mul_u64 (a, b);
31 res = (unsigned __int128) a * b;
33 if (res != res_ref)
34 abort();