From patchwork Thu Dec 1 15:30:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominik Vogt X-Patchwork-Id: 701567 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tV1Sw3sDcz9t1T for ; Fri, 2 Dec 2016 02:30:40 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ffOYFMA4"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:reply-to:references:mime-version :content-type:in-reply-to:message-id; q=dns; s=default; b=wEmUVQ H9gBPMmUNzedsD+Mw2KZdq9pbFwbh69g76nTMNPWSy7P1dNxT/2PdUk1hleihCcB y2cIeZAPwQfmkh2lYNH0GmmiP7ioRvwywKhld+vWnOHPD7Gh/dYZ2OsUtPlW3mGR sy2Nq45F/9fmxhC+FZWUbPWwHmfB3Y1rQSA2o= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:reply-to:references:mime-version :content-type:in-reply-to:message-id; s=default; bh=R7eEKGlHLW5C AYM1ht86xHw7DkY=; b=ffOYFMA4Dhq2Q5ds19qWHv+6qA+k3IZ0sKUMGTmk3v94 QevDjLL3SqEc74g5ZNu3eRvHhEhD4Te43L93nq842BXcG/qOKx9g6Xs5LuECHUxL DaTSkRDp0+oGHqtYUbbWwaEUuHe9sgzgNpNQA8RkDGKCwseJiqVqgrSsxGk/COI= Received: (qmail 86850 invoked by alias); 1 Dec 2016 15:30:28 -0000 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 Received: (qmail 86683 invoked by uid 89); 1 Dec 2016 15:30:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=sk:vogt@li, U*vogt, sk:vogtli, vogt@linux.vnet.ibm.com X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 01 Dec 2016 15:30:18 +0000 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uB1FU3vq070915 for ; Thu, 1 Dec 2016 10:30:16 -0500 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0b-001b2d01.pphosted.com with ESMTP id 272mvhexht-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 01 Dec 2016 10:30:15 -0500 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 1 Dec 2016 15:30:12 -0000 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 1 Dec 2016 15:30:11 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 64DD8219006C for ; Thu, 1 Dec 2016 15:29:22 +0000 (GMT) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uB1FUBtR31653986 for ; Thu, 1 Dec 2016 15:30:11 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id uB1FUAhL003008 for ; Thu, 1 Dec 2016 08:30:10 -0700 Received: from oc5510024614.ibm.com (sig-9-145-51-151.uk.ibm.com [9.145.51.151]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id uB1FUACE003001; Thu, 1 Dec 2016 08:30:10 -0700 Received: by oc5510024614.ibm.com (Postfix, from userid 500) id D95DF1AA22; Thu, 1 Dec 2016 16:30:08 +0100 (CET) Date: Thu, 1 Dec 2016 16:30:08 +0100 From: Dominik Vogt To: Bernd Schmidt Cc: gcc-patches@gcc.gnu.org, Andreas Krebbel , Ulrich Weigand Subject: Re: [PATCH v3] Do not simplify "(and (reg) (const bit))" to if_then_else. Reply-To: vogt@linux.vnet.ibm.com Mail-Followup-To: vogt@linux.vnet.ibm.com, Bernd Schmidt , gcc-patches@gcc.gnu.org, Andreas Krebbel , Ulrich Weigand References: <20161031195610.GA3558@linux.vnet.ibm.com> <4c9dd4a4-9f4f-048c-67d5-8ace6bd6eb8c@redhat.com> <20161111111028.GA30873@linux.vnet.ibm.com> <20161121123647.GA22233@linux.vnet.ibm.com> <9044f460-61af-3680-4ac4-5ac9d7ead673@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <9044f460-61af-3680-4ac4-5ac9d7ead673@redhat.com> User-Agent: Mutt/1.5.20 (2009-12-10) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16120115-0012-0000-0000-0000049C2DFA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16120115-0013-0000-0000-0000166DE480 Message-Id: <20161201153008.GA28115@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-12-01_12:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1612010266 On Thu, Dec 01, 2016 at 01:33:17PM +0100, Bernd Schmidt wrote: > On 11/21/2016 01:36 PM, Dominik Vogt wrote: > >diff --git a/gcc/combine.c b/gcc/combine.c > >index b22a274..457fe8a 100644 > >--- a/gcc/combine.c > >+++ b/gcc/combine.c > >@@ -5575,10 +5575,23 @@ combine_simplify_rtx (rtx x, machine_mode op0_mode, int in_dest, > > { > > rtx cop1 = const0_rtx; > > enum rtx_code cond_code = simplify_comparison (NE, &cond, &cop1); > >+ unsigned HOST_WIDE_INT nz; > > > > if (cond_code == NE && COMPARISON_P (cond)) > > return x; > > > >+ /* If the operation is an AND wrapped in a SIGN_EXTEND or ZERO_EXTEND > >+ with either operand being just a constant single bit value, do > >+ nothing since IF_THEN_ELSE is likely to increase the expression's > >+ complexity. */ > >+ if (HWI_COMPUTABLE_MODE_P (mode) > >+ && pow2p_hwi (nz = nonzero_bits (x, mode)) > >+ && ! ((code == SIGN_EXTEND || code == ZERO_EXTEND) > >+ && GET_CODE (XEXP (x, 0)) == AND > >+ && CONST_INT_P (XEXP (XEXP (x, 0), 0)) > >+ && UINTVAL (XEXP (XEXP (x, 0), 0)) == nz)) > >+ return x; > > It looks like this doesn't actually use cond or true/false_rtx. So > this could be placed just above the call to if_then_else_cond to > avoid unnecessary work. Ok if that works. It does. Version 3 attached, bootstrapped on s390x and regression tested on s390x biarch and s390. Ciao Dominik ^_^ ^_^ diff --git a/gcc/combine.c b/gcc/combine.c index a8dae89..52bde9e 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -5600,6 +5600,18 @@ combine_simplify_rtx (rtx x, machine_mode op0_mode, int in_dest, && OBJECT_P (SUBREG_REG (XEXP (x, 0))))))) { rtx cond, true_rtx, false_rtx; + unsigned HOST_WIDE_INT nz; + + /* If the operation is an AND wrapped in a SIGN_EXTEND or ZERO_EXTEND with + either operand being just a constant single bit value, do nothing since + IF_THEN_ELSE is likely to increase the expression's complexity. */ + if (HWI_COMPUTABLE_MODE_P (mode) + && pow2p_hwi (nz = nonzero_bits (x, mode)) + && ! ((code == SIGN_EXTEND || code == ZERO_EXTEND) + && GET_CODE (XEXP (x, 0)) == AND + && CONST_INT_P (XEXP (XEXP (x, 0), 0)) + && UINTVAL (XEXP (XEXP (x, 0), 0)) == nz)) + return x; cond = if_then_else_cond (x, &true_rtx, &false_rtx); if (cond != 0