http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55555
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> 2012-12-14
13:49:02 UTC ---
(In reply to comment #7)
> I've tried to rewrite this as C, but managed to turn it into something that is
> miscompiled at a different spot. The fortran testcase starts having
> __builtin_unreachable () in it in the *.cunroll pass, this one already in
> *.cunrolli pass. Still, I believe it doesn't do any out of bounds access
> anywhere. -O2 on x86_64-linux.
>
> double s[4] = { 1.0, 2.0, 3.0, 4.0 }, pol_x[2] = { 5.0, 6.0 };
>
> __attribute__((noinline)) int
> foo (void)
> {
> double coef_x[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
> int lxp = 0;
> if (lxp <= 1)
> do
> {
> double t = pol_x[lxp];
> long S;
> long l = lxp * 4L - 1;
> for (S = 1; S <= 4; S++)
> coef_x[S + l] = coef_x[S + l] + s[S - 1] * t;
> }
> while (lxp++ != 1);
> asm volatile ("" : : "r" (coef_x) : "memory");
> for (lxp = 0; lxp < 8; lxp++)
> if (coef_x[lxp] != ((lxp & 3) + 1) * (5.0 + (lxp >= 4)))
> __builtin_abort ();
> return 1;
> }
>
> int
> main ()
> {
> asm volatile ("" : : : "memory");
> if (!foo ())
> __builtin_abort ();
> return 0;
> }
>
> Works with r193067, fails with r193100, haven't tried to bisect exactly, but
> would guess this is r193098 again. For the outer loop it prints:
>
> Analyzing # of iterations of loop 1
> exit condition [0, + , 1](no_overflow) != 1
> bounds on difference of bases: 1 ... 1
> result:
> # of iterations 1, bounded by 1
> Loop 1 iterates 1 times.
> Loop 1 iterates at most 1 times.
>
> but that is wrong, the outer loop iterates exactly 2 times.
That's latch block executions, so one latch block execution is correct.