(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
powerpc/
pr106322.c
       1  /* { dg-do run } */
       2  /* { dg-options "-O2 -mdejagnu-cpu=power4" } */
       3  
       4  /* As PR106322, verify this can execute well (not abort).  */
       5  
       6  #define N 64
       7  typedef unsigned short int uh;
       8  typedef unsigned short int uw;
       9  uh a[N];
      10  uh b[N];
      11  uh c[N];
      12  uh e[N];
      13  
      14  __attribute__ ((noipa)) void
      15  foo ()
      16  {
      17    for (int i = 0; i < N; i++)
      18      c[i] = ((uw) b[i] * (uw) a[i]) >> 16;
      19  }
      20  
      21  __attribute__ ((optimize ("-O0"))) void
      22  init ()
      23  {
      24    for (int i = 0; i < N; i++)
      25      {
      26        a[i] = (uh) (0x7ABC - 0x5 * i);
      27        b[i] = (uh) (0xEAB + 0xF * i);
      28        e[i] = ((uw) b[i] * (uw) a[i]) >> 16;
      29      }
      30  }
      31  
      32  __attribute__ ((optimize ("-O0"))) void
      33  check ()
      34  {
      35    for (int i = 0; i < N; i++)
      36      {
      37        if (c[i] != e[i])
      38  	__builtin_abort ();
      39      }
      40  }
      41  
      42  int
      43  main ()
      44  {
      45    init ();
      46    foo ();
      47    check ();
      48  
      49    return 0;
      50  }