From f72b241d7e0d9df0c7ec896ba4ca28fc0f864f3a Mon Sep 17 00:00:00 2001
From: uweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Sun, 19 Jun 2005 13:29:45 +0000
Subject: [PATCH] 2005-06-19  Andreas Krebbel  <krebbel1@de.ibm.com>

	* combine.c (make_compound_operation): Use simplify_subreg.  Delete
	a optimization already done by simplify_subreg.


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

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index af13fe0f2cf9..ef767e236341 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2005-06-19  Andreas Krebbel  <krebbel1@de.ibm.com>
+
+	* combine.c (make_compound_operation): Use simplify_subreg.  Delete
+	a optimization already done by simplify_subreg.
+
 2005-06-19  Ulrich Weigand  <uweigand@de.ibm.com>
 
 	* loop.c (scan_loop): Do not consider insns setting the frame
diff --git a/gcc/combine.c b/gcc/combine.c
index d618c9fcf5ce..c4e6f95fa48b 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -6732,41 +6732,33 @@ make_compound_operation (rtx x, enum rtx_code in_code)
 	 what it originally did, do this SUBREG as a force_to_mode.  */
 
       tem = make_compound_operation (SUBREG_REG (x), in_code);
-      if (GET_CODE (tem) != GET_CODE (SUBREG_REG (x))
-	  && GET_MODE_SIZE (mode) < GET_MODE_SIZE (GET_MODE (tem))
-	  && subreg_lowpart_p (x))
-	{
-	  rtx newer = force_to_mode (tem, mode, ~(HOST_WIDE_INT) 0,
-				     NULL_RTX, 0);
 
-	  /* If we have something other than a SUBREG, we might have
-	     done an expansion, so rerun ourselves.  */
-	  if (GET_CODE (newer) != SUBREG)
-	    newer = make_compound_operation (newer, in_code);
+      {
+	rtx simplified;
+	simplified = simplify_subreg (GET_MODE (x), tem, GET_MODE (tem),
+				      SUBREG_BYTE (x));
 
-	  return newer;
-	}
+	if (simplified)
+	  tem = simplified;
 
-      /* If this is a paradoxical subreg, and the new code is a sign or
-	 zero extension, omit the subreg and widen the extension.  If it
-	 is a regular subreg, we can still get rid of the subreg by not
-	 widening so much, or in fact removing the extension entirely.  */
-      if ((GET_CODE (tem) == SIGN_EXTEND
-	   || GET_CODE (tem) == ZERO_EXTEND)
-	  && subreg_lowpart_p (x))
-	{
-	  if (GET_MODE_SIZE (mode) > GET_MODE_SIZE (GET_MODE (tem))
-	      || (GET_MODE_SIZE (mode) >
-		  GET_MODE_SIZE (GET_MODE (XEXP (tem, 0)))))
-	    {
-	      if (! SCALAR_INT_MODE_P (mode))
-		break;
-	      tem = gen_rtx_fmt_e (GET_CODE (tem), mode, XEXP (tem, 0));
-	    }
-	  else
-	    tem = gen_lowpart (mode, XEXP (tem, 0));
+	if (GET_CODE (tem) != GET_CODE (SUBREG_REG (x))
+	    && GET_MODE_SIZE (mode) < GET_MODE_SIZE (GET_MODE (tem))
+	    && subreg_lowpart_p (x))
+	  {
+	    rtx newer = force_to_mode (tem, mode, ~(HOST_WIDE_INT) 0,
+				       NULL_RTX, 0);
+	    
+	    /* If we have something other than a SUBREG, we might have
+	       done an expansion, so rerun ourselves.  */
+	    if (GET_CODE (newer) != SUBREG)
+	      newer = make_compound_operation (newer, in_code);
+	    
+	    return newer;
+	  }
+
+	if (simplified)
 	  return tem;
-	}
+      }
       break;
 
     default:
-- 
GitLab