(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
powerpc/
pr101596-3.c
       1  /* { dg-do run } */
       2  /* { dg-require-effective-target power10_hw } */
       3  /* { dg-options "-mdejagnu-cpu=power10 -O2 -ftree-vectorize -fno-vect-cost-model" } */
       4  
       5  /* Verify the execution goes well with shift count either 32 or 48.  */
       6  
       7  #define N 128
       8  
       9  typedef signed int si;
      10  typedef signed short sh;
      11  typedef signed long long sll;
      12  typedef unsigned int ui;
      13  typedef unsigned short uh;
      14  typedef unsigned long long ull;
      15  
      16  si si_a[N], si_b[N];
      17  ui ui_a[N], ui_b[N];
      18  sh sh_c[N];
      19  uh uh_c[N];
      20  
      21  #define TEST(NTYPE, TYPE, WTYPE, CNT)                                          \
      22    void __attribute__ ((noipa)) test_##TYPE##CNT ()                             \
      23    {                                                                            \
      24      for (int i = 0; i < N; i++)                                                \
      25        NTYPE##_c[i] = ((WTYPE) TYPE##_a[i] * (WTYPE) TYPE##_b[i]) >> CNT;       \
      26    }                                                                            \
      27                                                                                 \
      28    void __attribute__ ((noipa, optimize ("O1"))) check_##TYPE##CNT ()           \
      29    {                                                                            \
      30      test_##TYPE##CNT ();                                                       \
      31      for (int i = 0; i < N; i++)                                                \
      32        {                                                                        \
      33  	NTYPE exp = ((WTYPE) TYPE##_a[i] * (WTYPE) TYPE##_b[i]) >> CNT;        \
      34  	if (NTYPE##_c[i] != exp)                                               \
      35  	  __builtin_abort ();                                                  \
      36        }                                                                        \
      37    }
      38  
      39  TEST (sh, si, sll, 32)
      40  TEST (sh, si, sll, 48)
      41  TEST (uh, ui, ull, 32)
      42  TEST (uh, ui, ull, 48)
      43  
      44  int
      45  main ()
      46  {
      47  
      48    for (int i = 0; i < N; i++)
      49      {
      50        ui_a[i] = si_a[i] = 0x12345678ULL + 0x1000ULL * (i * 3 - 1);
      51        ui_b[i] = si_b[i] = 0x87654321ULL - 0x500000ULL * (i * 5 + 1);
      52      }
      53  
      54    check_si32 ();
      55    check_si48 ();
      56    check_ui32 ();
      57    check_ui48 ();
      58  }