OSDN Git Service

2010-01-26 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / pr29921-2.c
1 /* With -ffast-math, the latice value for sum2 used to change from NaN to
2    VARYING, in turn causing the lattice value of sum1 * sum2 change from
3    NaN to 0 (since sum1 is believed to be 0 at that moment, and
4    0 * VARYING = 0 with -ffast-math), which caused an ICE.  */
5
6 /* { dg-do compile } */
7 /* { dg-options "-O2 -ffast-math" } */
8
9 int
10 foo (float *array, int end)
11 {
12   int i;
13   float sum1, sum2;
14
15   sum2 = 0;
16   for (i = 0; i < end; i++)
17     sum2 = sum2+array[i];
18   sum2 = 1./sum2;
19   sum1 = 0.;
20   for (i = 0; i < end; i++)
21     sum1 = sum1+array[i];
22   sum1 = sum1 * sum2;
23   if (-10.0 / sum1 < 5.E-5)
24     end = 0;
25   return end;
26 }
27