From 5a32d03841c8db674ef3f6fb7e223b37c4122e46 Mon Sep 17 00:00:00 2001
From: Richard Kenner <kenner@gcc.gnu.org>
Date: Wed, 16 Nov 1994 07:47:58 -0500
Subject: [PATCH] (convert_move): Don't put FROM in a register if it is a
 SUBREG.

(store_expr): If don't want a value and storing into promoted
variable, do conversion at tree level; don't copy volatile MEM unless
want value, as comment says.

From-SVN: r8466
---
 gcc/expr.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/gcc/expr.c b/gcc/expr.c
index 0e2f3a36ae28..a1ecf253a1cb 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -1086,12 +1086,6 @@ convert_move (to, from, unsignedp)
       if ((code = can_extend_p (to_mode, from_mode, unsignedp))
 	  != CODE_FOR_nothing)
 	{
-	  /* If FROM is a SUBREG, put it into a register.  Do this
-	     so that we always generate the same set of insns for
-	     better cse'ing; if an intermediate assignment occurred,
-	     we won't be doing the operation directly on the SUBREG.  */
-	  if (optimize > 0 && GET_CODE (from) == SUBREG)
-	    from = force_reg (from_mode, from);
 	  emit_unop_insn (code, to, from, equiv_code);
 	  return;
 	}
@@ -2721,11 +2715,18 @@ store_expr (exp, target, want_value)
        and then convert to the wider mode.  Our value is the computed
        expression.  */
     {
+      /* If we don't want a value, we can do the conversion inside EXP,
+	 which will often result in some optimizations.  */
+      if (! want_value)
+	exp = convert (type_for_mode (GET_MODE (SUBREG_REG (target)),
+				      SUBREG_PROMOTED_UNSIGNED_P (target)),
+		       exp);
+	 
       temp = expand_expr (exp, NULL_RTX, VOIDmode, 0);
 
       /* If TEMP is a volatile MEM and we want a result value, make
 	 the access now so it gets done only once.  */
-      if (GET_CODE (temp) == MEM && MEM_VOLATILE_P (temp))
+      if (GET_CODE (temp) == MEM && MEM_VOLATILE_P (temp) && want_value)
 	temp = copy_to_reg (temp);
 
       /* If TEMP is a VOIDmode constant, use convert_modes to make
-- 
GitLab