re PR rtl-optimization/13037 ([gcse-lm] g77 generates incorrect code)

PR optimization/13037
	* loop.c (update_giv_derive): Ignore redundant sets of a biv when
	calculating how to derive a giv from a biv.

	* g77.f-torture/execute/13037.f: New test case.

From-SVN: r74572
This commit is contained in:
Roger Sayle 2003-12-12 14:31:18 +00:00 committed by Roger Sayle
parent 90d46c28f2
commit 77fec971c1
4 changed files with 73 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2003-12-12 Roger Sayle <roger@eyesopen.com>
PR optimization/13037
* loop.c (update_giv_derive): Ignore redundant sets of a biv when
calculating how to derive a giv from a biv.
2003-12-12 Neil Booth <neil@daikokuya.co.uk> 2003-12-12 Neil Booth <neil@daikokuya.co.uk>
PR preprocessor/12935 preprocessor/12952 preprocessor/13046 PR preprocessor/12935 preprocessor/12952 preprocessor/13046

View File

@ -6095,6 +6095,10 @@ update_giv_derive (const struct loop *loop, rtx p)
if (GET_CODE (p) == CODE_LABEL || GET_CODE (p) == JUMP_INSN if (GET_CODE (p) == CODE_LABEL || GET_CODE (p) == JUMP_INSN
|| biv->insn == p) || biv->insn == p)
{ {
/* Skip if location is the same as a previous one. */
if (biv->same)
continue;
for (giv = bl->giv; giv; giv = giv->next_iv) for (giv = bl->giv; giv; giv = giv->next_iv)
{ {
/* If cant_derive is already true, there is no point in /* If cant_derive is already true, there is no point in

View File

@ -1,3 +1,8 @@
2003-12-12 Roger Sayle <roger@eyesopen.com>
PR optimization/13037
* g77.f-torture/execute/13037.f: New test case.
2003-12-12 Nathan Sidwell <nathan@codesourcery.com> 2003-12-12 Nathan Sidwell <nathan@codesourcery.com>
PR c++/12881 PR c++/12881

View File

@ -0,0 +1,58 @@
c PR optimization/13037
c Contributed by Kirill Smelkov
c bug symptom: zeta(kkzc) seems to reference to zeta(kkzc-1) instead
c with gcc-3.2.2 it is OK, so it is a regression.
c
subroutine bug1(expnt)
implicit none
double precision zeta
common /bug1_area/zeta(3)
double precision expnt(3)
integer k, kkzc
kkzc=0
do k=1,3
kkzc = kkzc + 1
zeta(kkzc) = expnt(k)
enddo
c the following line activates the bug
call bug1_activator(kkzc)
end
c dummy subroutine
subroutine bug1_activator(inum)
implicit none
integer inum
end
c test driver
program test_bug1
implicit none
double precision zeta
common /bug1_area/zeta(3)
double precision expnt(3)
zeta(1) = 0.0d0
zeta(2) = 0.0d0
zeta(3) = 0.0d0
expnt(1) = 1.0d0
expnt(2) = 2.0d0
expnt(3) = 3.0d0
call bug1(expnt)
if ((zeta(1).ne.1) .or. (zeta(2).ne.2) .or. (zeta(3).ne.3)) then
call abort
endif
end