From patchwork Thu Mar 7 05:48:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chung-Ju Wu X-Patchwork-Id: 225727 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 6D89A2C0370 for ; Thu, 7 Mar 2013 16:48:40 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1363240121; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:In-Reply-To:References:Date:Message-ID: Subject:From:To:Cc:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=DAdMKPCuIoX4T1p+Yq/kJqpxs54=; b=eSQ0AnzTA3USRFM A299DG0Ixf4zAgfpqxs4nMaRSylmlHCjAGtc87k5RvfeKhbrjhDJxl8akFsmdIUR reRIcC3vm7eAKgf2lBympu0oGaES0sG5HGG1X2DP58uNssD9CIbPtyYU7wmf3gSe W+DthJOBfv4upyJrvHI+OwHF1IGU= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:MIME-Version:X-Received:Received:In-Reply-To:References:Date:Message-ID:Subject:From:To:Cc:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=T3gQ9+3k2PE/pqV+3blEnRhtIHPtPm2VkmMPuD0A36JrkRLxZW2Zk1x54LqH9T swpt3ZpjHTno47GGofRrwDipnayJBYZScJSKoSjdJEefPFo7ea7w2x9My0aQYIr0 mOmvK3JKunv98lzgwTrJPkQoznQ30za7uMgies5wF9dPU=; Received: (qmail 12512 invoked by alias); 7 Mar 2013 05:48:28 -0000 Received: (qmail 12498 invoked by uid 22791); 7 Mar 2013 05:48:27 -0000 X-SWARE-Spam-Status: No, hits=-5.0 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_UC X-Spam-Check-By: sourceware.org Received: from mail-pa0-f42.google.com (HELO mail-pa0-f42.google.com) (209.85.220.42) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 07 Mar 2013 05:48:21 +0000 Received: by mail-pa0-f42.google.com with SMTP id kq12so185420pab.1 for ; Wed, 06 Mar 2013 21:48:20 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.68.136.138 with SMTP id qa10mr23711521pbb.20.1362635300676; Wed, 06 Mar 2013 21:48:20 -0800 (PST) Received: by 10.68.84.197 with HTTP; Wed, 6 Mar 2013 21:48:20 -0800 (PST) In-Reply-To: <3489339.3GL29RjfmL@polaris> References: <3489339.3GL29RjfmL@polaris> Date: Thu, 7 Mar 2013 13:48:20 +0800 Message-ID: Subject: Re: [PATCH, combine] Fix host-specific behavior in simplify_compare_const() From: Chung-Ju Wu To: Eric Botcazou Cc: gcc-patches@gcc.gnu.org X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 2013/3/5 Eric Botcazou : >> In other words, any 32-bit target with 'need_64bit_hwint=yes' in config.gcc >> is not able to have benefit from this optimization because it never >> passes the condition test. >> >> >> My solution is to use GET_MODE_MASK(mode) to filter out all bits not >> in target mode. The following is my patch: > > The patch is OK for 4.9 once stage #1 is open if it passes bootstrap/regtest. Thanks for the approval. I will wait for 4.9 stage1 opening. The following is the new patch according to your suggestions: gcc/ChangeLog: * combine.c (simplify_compare_const): Use GET_MODE_MASK to filter out unnecessary bits in the constant power of two case. const_op = 0; Best regards, jasonwucj diff --git a/gcc/combine.c b/gcc/combine.c index 67bd776..ce2b583 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -10917,8 +10917,9 @@ simplify_compare_const (enum rtx_code code, rtx op0, rtx *pop1) && (code == EQ || code == NE || code == GE || code == GEU || code == LT || code == LTU) && mode_width <= HOST_BITS_PER_WIDE_INT - && exact_log2 (const_op) >= 0 - && nonzero_bits (op0, mode) == (unsigned HOST_WIDE_INT) const_op) + && exact_log2 (const_op & GET_MODE_MASK (mode)) >= 0 + && (nonzero_bits (op0, mode) + == (unsigned HOST_WIDE_INT) (const_op & GET_MODE_MASK (mode)))) { code = (code == EQ || code == GE || code == GEU ? NE : EQ);