From 72a64688ab463d4c89977ce87aeaf18ffa627871 Mon Sep 17 00:00:00 2001
From: mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 31 Dec 2003 18:41:28 +0000
Subject: [PATCH] 	* c-common.c (c_expand_expr): Remove code to return a
 value 	different from that returned by expand_expr. 	* expr.c (store_expr):
 Use the validity of a target MEM, rather 	than checking DECL_RTL (exp),
 to figure out if a copy is 	required.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@75273 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog  |  8 ++++++++
 gcc/c-common.c | 23 +++++------------------
 gcc/expr.c     | 12 +++++++-----
 3 files changed, 20 insertions(+), 23 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c7470546546..b27cd4c3288 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2003-12-31  Mark Mitchell  <mark@codesourcery.com>
+
+	* c-common.c (c_expand_expr): Remove code to return a value
+	different from that returned by expand_expr.
+	* expr.c (store_expr): Use the validity of a target MEM, rather
+	than checking DECL_RTL (exp), to figure out if a copy is
+	required.
+
 2003-12-31  Kazu Hirata  <kazu@cs.umass.edu>
 
 	* config/v850/lib1funcs.asm: Fix comment formatting.
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 3ba73dd2722..327a4dc463c 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -4064,7 +4064,6 @@ c_expand_expr (tree exp, rtx target, enum machine_mode tmode, int modifier)
 	tree rtl_expr;
 	rtx result;
 	bool preserve_result = false;
-	bool return_target = false;
 
 	if (STMT_EXPR_WARN_UNUSED_RESULT (exp) && target == const0_rtx)
 	  {
@@ -4112,20 +4111,10 @@ c_expand_expr (tree exp, rtx target, enum machine_mode tmode, int modifier)
 	    if (TREE_CODE (last) == SCOPE_STMT
 		&& TREE_CODE (expr) == EXPR_STMT)
 	      {
-		if (target && TREE_CODE (EXPR_STMT_EXPR (expr)) == VAR_DECL
-		    && DECL_RTL_IF_SET (EXPR_STMT_EXPR (expr)) == target)
-		  /* If the last expression is a variable whose RTL is the
-		     same as our target, just return the target; if it
-		     isn't valid expanding the decl would produce different
-		     RTL, and store_expr would try to do a copy.  */
-		  return_target = true;
-		else
-		  {
-		    /* Otherwise, note that we want the value from the last
-		       expression.  */
-		    TREE_ADDRESSABLE (expr) = 1;
-		    preserve_result = true;
-		  }
+		/* Otherwise, note that we want the value from the last
+		   expression.  */
+		TREE_ADDRESSABLE (expr) = 1;
+		preserve_result = true;
 	      }
 	  }
 
@@ -4133,9 +4122,7 @@ c_expand_expr (tree exp, rtx target, enum machine_mode tmode, int modifier)
 	expand_end_stmt_expr (rtl_expr);
 
 	result = expand_expr (rtl_expr, target, tmode, modifier);
-	if (return_target)
-	  result = target;
-	else if (preserve_result && GET_CODE (result) == MEM)
+	if (preserve_result && GET_CODE (result) == MEM)
 	  {
 	    if (GET_MODE (result) != BLKmode)
 	      result = copy_to_reg (result);
diff --git a/gcc/expr.c b/gcc/expr.c
index 93ab7e0c796..a38dee1851c 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -4253,11 +4253,13 @@ store_expr (tree exp, rtx target, int want_value)
 			      || side_effects_p (target))))
       && TREE_CODE (exp) != ERROR_MARK
       && ! dont_store_target
-	 /* If store_expr stores a DECL whose DECL_RTL(exp) == TARGET,
-	    but TARGET is not valid memory reference, TEMP will differ
-	    from TARGET although it is really the same location.  */
-      && (TREE_CODE_CLASS (TREE_CODE (exp)) != 'd'
-	  || target != DECL_RTL_IF_SET (exp))
+      /* If store_expr stores a DECL whose DECL_RTL(exp) == TARGET,
+	 but TARGET is not valid memory reference, TEMP will differ
+	 from TARGET although it is really the same location.  */
+      && !(GET_CODE (target) == MEM
+	   && GET_CODE (XEXP (target, 0)) != QUEUED
+	   && (!memory_address_p (GET_MODE (target), XEXP (target, 0))
+	       || (flag_force_addr && !REG_P (XEXP (target, 0)))))
       /* If there's nothing to copy, don't bother.  Don't call expr_size
 	 unless necessary, because some front-ends (C++) expr_size-hook
 	 aborts on objects that are not supposed to be bit-copied or
-- 
GitLab