Let tree_single_nonzero_warnv_p use range information
[official-gcc.git] / gcc / testsuite / gcc.dg / pr30957-1.c
blob6a0ed2045c1ee08f2844c289be7d23ebb9a69b1d
1 /* { dg-do run } */
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" } */
8 extern void abort (void);
9 extern void exit (int);
11 float __attribute__((noinline))
12 foo (float d, int n)
14 unsigned i;
15 float accum = d;
17 for (i = 0; i < n; i++)
18 accum += d;
20 return accum;
23 int
24 main ()
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);
36 /* { dg-final { scan-rtl-dump "Expanding Accumulator" "loop2_unroll" } } */