From: "H.J. Lu" <hongjiu.lu@intel.com>
To: gcc-patches@gcc.gnu.org
Subject: PATCH [3/n]: Prepare x32: PR rtl-optimization/49088: Combine fails to properly handle zero-extension and signed int constant
Date: Sat, 11 Jun 2011 15:59:00 -0000 [thread overview]
Message-ID: <20110611154850.GA19963@intel.com> (raw)
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. */
reply other threads:[~2011-06-11 15:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110611154850.GA19963@intel.com \
--to=hongjiu.lu@intel.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hjl.tools@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).