(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
pr30957-1.c
       1  /* { dg-do run { xfail { mmix-*-* } } } */
       2  /* We don't (and don't want to) perform this optimisation on soft-float targets,
       3     where each addition is a library call.  /
       4  /* { dg-require-effective-target hard_float } */
       5  /* -fassociative-math requires -fno-trapping-math and -fno-signed-zeros. */
       6  /* { dg-options "-O2 -funroll-loops -fassociative-math -fno-trapping-math -fno-signed-zeros -fvariable-expansion-in-unroller -fdump-rtl-loop2_unroll" } */
       7  
       8  extern void abort (void);
       9  extern void exit (int);
      10  
      11  float __attribute__((noinline))
      12  foo (float d, int n)
      13  {
      14    unsigned i;
      15    float accum = d;
      16  
      17    for (i = 0; i < n; i++)
      18      accum += d;
      19  
      20    return accum;
      21  }
      22  
      23  int
      24  main ()
      25  {
      26    /* When compiling standard compliant we expect foo to return -0.0.  But the
      27       variable expansion during unrolling optimization (for this testcase enabled
      28       by non-compliant -fassociative-math) instantiates copy(s) of the
      29       accumulator which it initializes with +0.0.  Hence we expect that foo
      30       returns +0.0.  */
      31    if (__builtin_copysignf (1.0, foo (0.0 / -5.0, 10)) != 1.0)
      32      abort ();
      33    exit (0);
      34  }
      35  
      36  /* { dg-final { scan-rtl-dump "Expanding Accumulator" "loop2_unroll" { xfail mmix-*-* } } } */