(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
i386/
bmi2-mulx64-1.c
       1  /* { dg-do run { target { bmi2 && { ! ia32 } } } } */
       2  /* { dg-options "-mbmi2 -O2" } */
       3  
       4  #include "bmi2-check.h"
       5  
       6  __attribute__((noinline))
       7  unsigned __int128
       8  calc_mul_u64 (unsigned long long volatile a, unsigned long long b)
       9  {
      10    unsigned __int128 res = 0;
      11    int i;
      12    for (i = 0; i < b; ++i)
      13      res += (unsigned __int128) a;
      14  
      15    return res;
      16  }
      17  
      18  static void
      19  bmi2_test ()
      20  {
      21    unsigned i;
      22    unsigned long long a = 0xce7ace0ce7ace0;
      23    unsigned long long b = 0xface;
      24    unsigned __int128 res, res_ref;
      25  
      26    for (i=0; i<5; ++i) {
      27      a = a * (i + 1);
      28      b = b / (i + 1);
      29  
      30      res_ref = calc_mul_u64 (a, b);
      31      res = (unsigned __int128) a * b;
      32  
      33      if (res != res_ref)
      34        abort();
      35    }
      36  }