1  /* { dg-do run } */
       2  /* { dg-require-effective-target fma } */
       3  /* { dg-options "-O3 -mfma -save-temps" } */
       4  
       5  #include "fma-check.h"
       6  
       7  void __attribute__((noipa))
       8  check_fmsubadd (double * __restrict a, double *b, double *c, int n)
       9  {
      10    for (int i = 0; i < n; ++i)
      11      {
      12        a[2*i + 0] = b[2*i + 0] * c[2*i + 0] + a[2*i + 0];
      13        a[2*i + 1] = b[2*i + 1] * c[2*i + 1] - a[2*i + 1];
      14      }
      15  }
      16  
      17  static void
      18  fma_test (void)
      19  {
      20    double a[4], b[4], c[4];
      21    for (int i = 0; i < 4; ++i)
      22      {
      23        a[i] = i;
      24        b[i] = 3*i;
      25        c[i] = 7*i;
      26      }
      27    check_fmsubadd (a, b, c, 2);
      28    const double d[4] = { 0., 20., 86., 186. };
      29    for (int i = 0; i < 4; ++i)
      30      if (a[i] != d[i])
      31        __builtin_abort ();
      32  }
      33  
      34  /* { dg-final { scan-assembler "fmsubadd...pd" } } */