(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
i386/
vect-alignment-peeling-1.c
       1  /* { dg-do run { target lp64 } } */
       2  /* This is a test exercising peeling for alignment for a negative step
       3     vector loop.  We're forcing atom tuning here because that has a higher
       4     unaligned vs aligned cost unlike most other archs.  */
       5  /* { dg-options "-O3 -march=x86-64 -mtune=atom -fdump-tree-vect-details -save-temps" } */
       6  
       7  float a[1024], b[1024];
       8  
       9  void __attribute__((noipa)) foo1 ()
      10  {
      11    for (int i = 507; i > 1; --i)
      12      a[i] = b[i] * 2.;
      13  }
      14  void __attribute__((noipa)) foo2 ()
      15  {
      16    for (int i = 506; i > 1; --i)
      17      a[i] = b[i] * 2.;
      18  }
      19  void __attribute__((noipa)) foo3 ()
      20  {
      21    for (int i = 505; i > 1; --i)
      22      a[i] = b[i] * 2.;
      23  }
      24  void __attribute__((noipa)) foo4 ()
      25  {
      26    for (int i = 504; i > 1; --i)
      27      a[i] = b[i] * 2.;
      28  }
      29  void __attribute__((noipa)) foo5 (int start)
      30  {
      31    for (int i = start; i > 1; --i)
      32      a[i] = b[i] * 2.;
      33  }
      34  
      35  int main()
      36  {
      37    for (int i = 2; i < 508; ++i)
      38      {
      39        __asm__ volatile ("" : : : "memory");
      40        b[i] = i;
      41      }
      42    foo1 ();
      43    for (int i = 2; i < 508; ++i)
      44      if (a[i] != 2*i)
      45        __builtin_abort ();
      46  
      47    for (int i = 2; i < 507; ++i)
      48      {
      49        __asm__ volatile ("" : : : "memory");
      50        b[i] = i;
      51      }
      52    foo2 ();
      53    for (int i = 2; i < 507; ++i)
      54      if (a[i] != 2*i)
      55        __builtin_abort ();
      56  
      57    for (int i = 2; i < 506; ++i)
      58      {
      59        __asm__ volatile ("" : : : "memory");
      60        b[i] = i;
      61      }
      62    foo3 ();
      63    for (int i = 2; i < 506; ++i)
      64      if (a[i] != 2*i)
      65        __builtin_abort ();
      66  
      67    for (int i = 2; i < 505; ++i)
      68      {
      69        __asm__ volatile ("" : : : "memory");
      70        b[i] = i;
      71      }
      72    foo4 ();
      73    for (int i = 2; i < 505; ++i)
      74      if (a[i] != 2*i)
      75        __builtin_abort ();
      76  
      77    for (int i = 2; i < 506; ++i)
      78      {
      79        __asm__ volatile ("" : : : "memory");
      80        b[i] = i;
      81      }
      82    foo5 (505);
      83    for (int i = 2; i < 506; ++i)
      84      if (a[i] != 2*i)
      85        __builtin_abort ();
      86  }
      87  
      88  /* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 4 "vect" } } */ 
      89  /* Verify all vector accesses are emitted as aligned.  */
      90  /* { dg-final { scan-assembler-not "movup" } } */