(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
powerpc/
bmi2-mulx64-1.c
       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 __int128
      11  calc_mul_u64 (unsigned long long volatile a, unsigned long long b)
      12  {
      13    unsigned __int128 res = 0;
      14    int i;
      15    for (i = 0; i < b; ++i)
      16      res += (unsigned __int128) a;
      17  
      18    return res;
      19  }
      20  
      21  static void
      22  bmi2_test ()
      23  {
      24    unsigned i;
      25    unsigned long long a = 0xce7ace0ce7ace0;
      26    unsigned long long b = 0xface;
      27    unsigned __int128 res, res_ref;
      28  
      29    for (i=0; i<5; ++i) {
      30      a = a * (i + 1);
      31      b = b / (i + 1);
      32  
      33      res_ref = calc_mul_u64 (a, b);
      34      res = (unsigned __int128) a * b;
      35  
      36      if (res != res_ref)
      37        abort();
      38    }
      39  }