PR middle-end/46637
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 25 Nov 2010 18:00:47 +0000 (18:00 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 25 Nov 2010 18:00:47 +0000 (18:00 +0000)
* combine.c (try_combine): When substing i2dest for i2src, pass
1 as last argument even if
i0_feeds_i1_n && i1_feeds_i2_n && i0dest_in_i0src.

* gcc.c-torture/compile/pr46637.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167148 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr46637.c [new file with mode: 0644]

index 57536cd..d67f499 100644 (file)
@@ -1,3 +1,10 @@
+2010-11-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/46637
+       * combine.c (try_combine): When substing i2dest for i2src, pass
+       1 as last argument even if
+       i0_feeds_i1_n && i1_feeds_i2_n && i0dest_in_i0src.
+
 2010-11-25  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR middle-end/46647
index c557e8c..a8ce701 100644 (file)
@@ -3096,10 +3096,12 @@ try_combine (rtx i3, rtx i2, rtx i1, rtx i0, int *new_direct_jump_p)
       /* If I1 feeds into I2 and I1DEST is in I1SRC, we need to make a unique
         copy of I2SRC each time we substitute it, in order to avoid creating
         self-referential RTL when we will be substituting I1SRC for I1DEST
-        later.  Likewise if I0 feeds into I2 and I0DEST is in I0SRC.  */
+        later.  Likewise if I0 feeds into I2, either directly or indirectly
+        through I1, and I0DEST is in I0SRC.  */
       newpat = subst (PATTERN (i3), i2dest, i2src, 0,
                      (i1_feeds_i2_n && i1dest_in_i1src)
-                     || (i0_feeds_i2_n && i0dest_in_i0src));
+                     || ((i0_feeds_i2_n || (i0_feeds_i1_n && i1_feeds_i2_n))
+                         && i0dest_in_i0src));
       substed_i2 = 1;
 
       /* Record whether I2's body now appears within I3's body.  */
index 798012f..b19b812 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/46637
+       * gcc.c-torture/compile/pr46637.c: New test.
+
 2010-11-25  H.J. Lu  <hongjiu.lu@intel.com>
 
        * gfortran.dg/pr46519-1.f: Add -mtune=generic.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr46637.c b/gcc/testsuite/gcc.c-torture/compile/pr46637.c
new file mode 100644 (file)
index 0000000..c765949
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR middle-end/46637 */
+
+struct S { int s[5]; } *p;
+
+void
+foo (long x)
+{
+  long a = x == 1 ? 4L : 1L;
+  asm ("" : "+m" (p->s[a]));
+  p->s[0]++;
+}