Debian Codegraph @

gcc/testsuite/gcc.target/powerpc/bmi2-mulx32-1.c

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