1 /* { dg-do run { target { bmi2 && ia32 } } } */ 2 /* { dg-options "-mbmi2 -O2" } */ 3 4 #include "bmi2-check.h" 5 6 __attribute__((noinline)) 7 unsigned long long calc_mul_u32(unsigned volatile a,unsigned b)8calc_mul_u32 (unsigned volatile a, unsigned b) 9 { 10 unsigned long long res = 0; 11 int i; 12 for (i = 0; i < b; ++i) 13 res += a; 14 15 return res; 16 } 17 18 __attribute__((noinline, regparm (2))) 19 unsigned long long gen_mulx(unsigned a,unsigned b)20gen_mulx (unsigned a, unsigned b) 21 { 22 unsigned long long res; 23 24 res = (unsigned long long)a * b; 25 26 return res; 27 } 28 29 static void bmi2_test()30bmi2_test () 31 { 32 unsigned i; 33 unsigned a = 0xce7ace0; 34 unsigned b = 0xfacefff; 35 unsigned long long res, res_ref; 36 37 for (i = 0; i < 5; ++i) { 38 a = a * (i + 1); 39 b = b / (i + 1); 40 41 res_ref = calc_mul_u32 (a, b); 42 res = gen_mulx (a, b); 43 44 if (res != res_ref) 45 abort(); 46 } 47 } 48