From patchwork Mon Oct 31 19:56:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominik Vogt X-Patchwork-Id: 689586 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 3t74qt4lCXz9s2Q for ; Tue, 1 Nov 2016 06:56:25 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=hz5ClHrn; 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:mime-version:content-type :message-id; q=dns; s=default; b=tAOuZbYGFV4D31Ih4RtWmiok2AxY1bM nRzyJaVjyw+pqY+LaPBGpaIcEv3+Rq03piGNuJ2ZxzAS/M6eyX12Mtl8Qvp8n4I/ ni27eWhCEU6GhOWrXHu+lDubovNRAjpiV5tNeDt5pwJkiUPzP/NMeTGCQQsFbh7J gy17y7pnJU2g= 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:mime-version:content-type :message-id; s=default; bh=6l7Vb3Wzzd0JNvmjWdCEwSgEa/4=; b=hz5Cl HrnLdpOAsCzlFFuQ0Ru1iFXl1K6p+HUo9DPzVI+xhx8oHJ9y1WAXeqavuW9NNFaG m7JW4iWiG4wy+dYCx3SJEcmDsE/0PqE09AawZvrzj8PFUi/rXsar4Lk2aJrhNSkC vlflx+MjPmu/QPGsSkG7qSjT0NoBtV3qpVvdrw= Received: (qmail 87538 invoked by alias); 31 Oct 2016 19:56:15 -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 87448 invoked by uid 89); 31 Oct 2016 19:56:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_SEMBACKSCATTER autolearn=no version=3.3.2 spammy=vogt X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 31 Oct 2016 19:56:13 +0000 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u9VJs9Uh128365 for ; Mon, 31 Oct 2016 15:56:11 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 26e6xe3f5d-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 31 Oct 2016 15:56:11 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 31 Oct 2016 19:56:08 -0000 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 31 Oct 2016 19:56:07 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 41FFA17D8024 for ; Mon, 31 Oct 2016 19:58:24 +0000 (GMT) Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u9VJtsk941484454; Mon, 31 Oct 2016 19:56:07 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A0E6752045; Mon, 31 Oct 2016 18:55:00 +0000 (GMT) Received: from oc5510024614.ibm.com (unknown [9.145.36.15]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 318745203F; Mon, 31 Oct 2016 18:55:00 +0000 (GMT) Received: by oc5510024614.ibm.com (Postfix, from userid 500) id 7B67F10E9D; Mon, 31 Oct 2016 20:56:10 +0100 (CET) Date: Mon, 31 Oct 2016 20:56:10 +0100 From: Dominik Vogt To: gcc-patches@gcc.gnu.org Cc: Andreas Krebbel , Ulrich Weigand Subject: [PATCH] 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, gcc-patches@gcc.gnu.org, Andreas Krebbel , Ulrich Weigand MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16103119-0040-0000-0000-000002F8E09B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16103119-0041-0000-0000-00001DAD10FE Message-Id: <20161031195610.GA3558@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-10-31_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1610310347 The attached patch does a little change in combine.c:combine_simplify_rtx() to prevent a "simplification" where the rtl code gets more complex in reality. The complete description of the change can be found in the commit comment in the attached patch. The patch reduces the number of patterns in the s390 backend and slightly reduces the size of the compiled SPEC2006 code. (Code size or runtime only tested on s390x with -m64.) It is theoretically possible that this patch leads to somewhat worse code on some target if that only has a pattern for the formerly replaced rtl expression but not for the original one. The patch has passed the testsuite on s390, s390x biarch, x86_64 and Power biarch. --- (I'm not sure whether the const_int expression can appear in both operands or only as the second. If the latter is the case, the conditions can be simplified a bit.) What do you think about this patch? Ciao Dominik ^_^ ^_^ diff --git a/gcc/combine.c b/gcc/combine.c index b22a274..244669d 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -9103,9 +9103,25 @@ if_then_else_cond (rtx x, rtx *ptrue, rtx *pfalse) return x; } - /* Likewise for 0 or a single bit. */ + /* Likewise for 0 or a single bit. + If the operation is an AND (possibly 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. */ else if (HWI_COMPUTABLE_MODE_P (mode) - && pow2p_hwi (nz = nonzero_bits (x, mode))) + && pow2p_hwi (nz = nonzero_bits (x, mode)) + && ! (code == AND + && ((CONST_INT_P (XEXP (x, 0)) + && UINTVAL (XEXP (x, 0)) == nz) + || (CONST_INT_P (XEXP (x, 1)) + && UINTVAL (XEXP (x, 1)) == nz))) + && ! ((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) + || (CONST_INT_P (XEXP (XEXP (x, 0), 1)) + && UINTVAL (XEXP (XEXP (x, 0), 1)) == nz))) + ) { *ptrue = gen_int_mode (nz, mode), *pfalse = const0_rtx; return x;