re PR middle-end/46297 (gfortran.dg/g77/980701-0.f FAILs with -Os -fno-asynchronous...
authorJeff Law <law@redhat.com>
Thu, 18 Nov 2010 14:34:29 +0000 (07:34 -0700)
committerJeff Law <law@gcc.gnu.org>
Thu, 18 Nov 2010 14:34:29 +0000 (07:34 -0700)
PR middle-end-optimization/46297
* postreload.c (reload_combine_note_store): Deal with embedded
side effects in MEM expressions.

* gfortran.dg/pr46297.f: New test.

From-SVN: r166905

gcc/ChangeLog
gcc/postreload.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr46297.f [new file with mode: 0644]

index 9490dd36ebe9f9ff1054d9e411ad6599f2bd160a..1fbec11aef52a9fe0403c660993ede0d9325f304 100644 (file)
@@ -1,3 +1,9 @@
+2010-11-18  Jeff Law  <law@redhat.com>
+
+       PR middle-end-optimization/46297
+       * postreload.c (reload_combine_note_store): Deal with embedded
+       side effects in MEM expressions.
+
 2010-11-18  Richard Guenther  <rguenther@suse.de>
 
        PR lto/45089
index 1772c9e058d06b8cd1a1f52e776c6248cfe0f2b0..6bbdf3adeff401291d02cb8abca6517a2d0ae39e 100644 (file)
@@ -1409,6 +1409,31 @@ reload_combine_note_store (rtx dst, const_rtx set, void *data ATTRIBUTE_UNUSED)
                                   GET_MODE (dst));
       dst = SUBREG_REG (dst);
     }
+
+  /* Some targets do argument pushes without adding REG_INC notes.  */
+
+  if (MEM_P (dst))
+    {
+      dst = XEXP (dst, 0);
+      if (GET_CODE (dst) == PRE_INC || GET_CODE (dst) == POST_INC
+         || GET_CODE (dst) == PRE_DEC || GET_CODE (dst) == POST_DEC)
+       {
+         regno = REGNO (XEXP (dst, 0));
+         mode = GET_MODE (XEXP (dst, 0));
+         for (i = hard_regno_nregs[regno][mode] - 1 + regno; i >= regno; i--)
+           {
+             /* We could probably do better, but for now mark the register
+                as used in an unknown fashion and set/clobbered at this
+                insn.  */
+             reg_state[i].use_index = -1;
+             reg_state[i].store_ruid = reload_combine_ruid;
+             reg_state[i].real_store_ruid = reload_combine_ruid;
+           }
+       }
+      else
+        return;
+    }
+
   if (!REG_P (dst))
     return;
   regno += REGNO (dst);
index 6d2303a10e5ba6787fcb26bb4a61c8f2f3a5aba7..3a6e36a3fe19e6bd786e1a077bf065c8279789aa 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-18  Jeff Law  <law@redhat.com>
+
+       PR middle-end-optimization/46297
+       * gfortran.dg/pr46297.f: New test.
+
 2010-11-17  Steve Ellcey  <sje@cup.hp.com>
 
        PR middle-end/31490
diff --git a/gcc/testsuite/gfortran.dg/pr46297.f b/gcc/testsuite/gfortran.dg/pr46297.f
new file mode 100644 (file)
index 0000000..3335760
--- /dev/null
@@ -0,0 +1,25 @@
+! { dg-options "-Os -fno-asynchronous-unwind-tables" }
+! { dg-do run }
+
+      real r1(5), r2(5), r3(5)
+      real s1(2), s2(2), s3(2)
+      double precision d1, d2, d3
+      equivalence (r3, s3(2))
+      equivalence (d3, r3(2))
+      s1(1) = 1.
+      s3(1) = 3.
+      r3(1) = 3.
+      d3 = 30.
+      i3 = 3
+      call x (s1, r1, d1, i1, s2, r2, d2, i2, s3, r3, d3, i3)
+      end
+      subroutine x (s1, r1, d1, i1, s2, r2, d2, i2, s3, r3, d3, i3)
+      real r1(5), r2(5), r3(5)
+      real s1(2), s2(2), s3(2)
+      double precision d1, d2, d3
+      if (s1(1) .ne. 1.) call abort
+      if (s3(1) .ne. 3.) call abort
+      if (r3(1) .ne. 3.) call abort
+      if (d3 .ne. 30.) call abort
+      if (i3 .ne. 3) call abort
+      end