From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23658 invoked by alias); 11 Jun 2011 15:49:11 -0000 Received: (qmail 23647 invoked by uid 22791); 11 Jun 2011 15:49:10 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,NO_DNS_FOR_FROM,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga03.intel.com (HELO mga03.intel.com) (143.182.124.21) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 11 Jun 2011 15:48:55 +0000 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 11 Jun 2011 08:48:54 -0700 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.135]) by azsmga001.ch.intel.com with ESMTP; 11 Jun 2011 08:48:54 -0700 Received: by gnu-6.sc.intel.com (Postfix, from userid 500) id 020A9C2266; Sat, 11 Jun 2011 08:48:50 -0700 (PDT) Date: Sat, 11 Jun 2011 15:59:00 -0000 From: "H.J. Lu" 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 Message-ID: <20110611154850.GA19963@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-06/txt/msg00915.txt.bz2 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 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. */