This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/54932] New: Invalid loop code generated by Fortran FE for loops with bounds in HIGH(type)
- From: "hubicka at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 15 Oct 2012 11:45:38 +0000
- Subject: [Bug fortran/54932] New: Invalid loop code generated by Fortran FE for loops with bounds in HIGH(type)
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54932
Bug #: 54932
Summary: Invalid loop code generated by Fortran FE for loops
with bounds in HIGH(type)
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: hubicka@gcc.gnu.org
The following fortran testcase (derrived from do-1.f90):
! { dg-do run }
! Program to check corner cases for DO statements.
program do_1
implicit none
integer i, j
! limit=HUGE(i), step 1
j = 0
do i = HUGE(i) - 10, HUGE(i), 1
j = j + 1
end do
if (j .ne. 11) call abort
end program
gets invalid estimate on number of iterations of the loop
Statement i_9 = i_8 + 1;
is executed at most 9 (bounded by 9) + 1 times in loop 1.
Loop 1 iterates at most 9 times.
(should be 10) this is because:
<bb 3>:
# i_8 = PHI <2147483637(2), i_9(3)>
# j_6 = PHI <0(2), j_7(3)>
# DEBUG j => j_6
# DEBUG i => i_8
j_7 = j_6 + 1;
# DEBUG j => j_7
i_9 = i_8 + 1;
# DEBUG i => i_9
if (i_8 == 2147483647)
goto <bb 4>;
else
goto <bb 3>;
the loop is produce din a way that i_9 overflows in the last iteration. It is
unused by according to discussion with Richard on IRC the program is not valid.
This is already wrong in the output from the fortran FE:
<bb 3>:
j = j + 1;
test (&i);
i.1 = i;
D.1852 = i.1 == 2147483647;
i.1 = i;
i.2 = i.1 + 1;
i = i.2;
if (D.1852 != 0)
goto <bb 4>;
else
goto <bb 3>;
the increment really should happen in the latch block.
Or is the testcase bogus?
Honza