re PR rtl-optimization/13037 ([gcse-lm] g77 generates incorrect code)
authorRoger Sayle <roger@eyesopen.com>
Fri, 12 Dec 2003 14:31:18 +0000 (14:31 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Fri, 12 Dec 2003 14:31:18 +0000 (14:31 +0000)
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

gcc/ChangeLog
gcc/loop.c
gcc/testsuite/ChangeLog
gcc/testsuite/g77.f-torture/execute/13037.f [new file with mode: 0644]

index ad91bf6c5f49c783c0fc82d07993b5d9da308700..56fb00f4ad6ed0ddd6968213c045c1003c1c773d 100644 (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>
 
        PR preprocessor/12935 preprocessor/12952 preprocessor/13046
index e1e85e83fbb07078984b27f0fcca8323ff8943e5..8deb398b912400dcd426867d8778a9be78b8bdd0 100644 (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
          || 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)
            {
              /* If cant_derive is already true, there is no point in
index eee3f585f9b5f8a43b63538129ce89d1e7de8170..f206b5048bbfec86686a88968337e21e2c42d4bb 100644 (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>
 
        PR c++/12881
diff --git a/gcc/testsuite/g77.f-torture/execute/13037.f b/gcc/testsuite/g77.f-torture/execute/13037.f
new file mode 100644 (file)
index 0000000..daafc52
--- /dev/null
@@ -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
+