public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* PATCH [3/n]: Prepare x32: PR rtl-optimization/49088: Combine fails to properly handle zero-extension and signed int constant
@ 2011-06-11 15:59 H.J. Lu
  0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 2011-06-11 15:59 UTC (permalink / raw)
  To: gcc-patches

See:

http://gcc.gnu.org/ml/gcc-patches/2011-05/msg02150.html

for an analysis.  OK for trunk?

Thanks.


H.J.
---
2011-05-21  H.J. Lu  <hongjiu.lu@intel.com>

	PR rtl-optimization/49088
	* combine.c (force_to_mode): If X is narrower than MODE and we
	want all the bits in X's mode, just use the operand when it
	is CONST_INT.

diff --git a/gcc/combine.c b/gcc/combine.c
index 8af86f2..710fe0e 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -8321,8 +8321,26 @@ force_to_mode (rtx x, enum machine_mode mode, unsigned HOST_WIDE_INT mask,
       /* For most binary operations, just propagate into the operation and
 	 change the mode if we have an operation of that mode.  */
 
-      op0 = force_to_mode (XEXP (x, 0), mode, mask, next_select);
-      op1 = force_to_mode (XEXP (x, 1), mode, mask, next_select);
+      /* If X is narrower than MODE and we want all the bits in X's
+	 mode, just use the operand when it is CONST_INT.  */
+      if (SCALAR_INT_MODE_P (mode)
+	  && GET_MODE_SIZE (GET_MODE (x)) < GET_MODE_SIZE (mode)
+	  && (GET_MODE_MASK (GET_MODE (x)) & ~mask) == 0)
+	{
+	  if (CONST_INT_P (XEXP (x, 0)))
+	    op0 = XEXP (x, 0);
+	  else
+	    op0 = force_to_mode (XEXP (x, 0), mode, mask, next_select);
+	  if (CONST_INT_P (XEXP (x, 1)))
+	    op1 = XEXP (x, 1);
+	  else
+	    op1 = force_to_mode (XEXP (x, 1), mode, mask, next_select);
+	}
+      else
+	{
+	  op0 = force_to_mode (XEXP (x, 0), mode, mask, next_select);
+	  op1 = force_to_mode (XEXP (x, 1), mode, mask, next_select);
+	}
 
       /* If we ended up truncating both operands, truncate the result of the
 	 operation instead.  */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-06-11 15:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-11 15:59 PATCH [3/n]: Prepare x32: PR rtl-optimization/49088: Combine fails to properly handle zero-extension and signed int constant H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).