From 2cc00ea2dd56b39953872215d7e889d3ac9dd3a9 Mon Sep 17 00:00:00 2001
From: aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 18 Jul 2003 18:23:30 +0000
Subject: [PATCH] * combine.c (combinable_i3pat): Don't forbid occurrences of
 i2dest or i1dest in inner_dest if inner_dest is a mem.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@69566 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog |  5 +++++
 gcc/combine.c | 11 ++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5aeacafee43d..644da7bf3238 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+Fri Jul 18 15:22:28 2003  Alexandre Oliva  <aoliva@redhat.com>
+
+	* combine.c (combinable_i3pat): Don't forbid occurrences of
+	i2dest or i1dest in inner_dest if inner_dest is a mem.
+
 Fri Jul 18 17:05:57 CEST 2003  Jan Hubicka  <jh@suse.cz>
 
 	* cgraph.c (cgraph_remove_node): Clear the hash table slot.
diff --git a/gcc/combine.c b/gcc/combine.c
index 5a752014873f..883f504a50b8 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -1301,9 +1301,14 @@ combinable_i3pat (rtx i3, rtx *loc, rtx i2dest, rtx i1dest,
 	     || GET_CODE (inner_dest) == ZERO_EXTRACT)
 	inner_dest = XEXP (inner_dest, 0);
 
-      /* Check for the case where I3 modifies its output, as
-	 discussed above.  */
-      if ((inner_dest != dest
+      /* Check for the case where I3 modifies its output, as discussed
+	 above.  We don't want to prevent pseudos from being combined
+	 into the address of a MEM, so only prevent the combination if
+	 i1 or i2 set the same MEM.  */
+      if ((inner_dest != dest &&
+	   (GET_CODE (inner_dest) != MEM
+	    || rtx_equal_p (i2dest, inner_dest)
+	    || (i1dest && rtx_equal_p (i1dest, inner_dest)))
 	   && (reg_overlap_mentioned_p (i2dest, inner_dest)
 	       || (i1dest && reg_overlap_mentioned_p (i1dest, inner_dest))))
 
-- 
GitLab