From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id B46DC3858C78 for ; Mon, 21 Aug 2023 01:37:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B46DC3858C78 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37L1Rf5H029232; Mon, 21 Aug 2023 01:37:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=8qiOPL+AxSzJ04IfJ4YVW22pXMaPUHq0ZlaGmw8qAgY=; b=THuG9fT37xNMbknfCqVnTmo0oTe79p0jp2w7P/of3aR6eq6rDixMd25Vl8V9i8rORUta DXDhAGanOFYRfSDnuBBn3gWFktk/eYarxFfh63AXQdEUp6kheD1O6u5CHu73yXGc1CvH Mvcq/p9CTYy/rSd4i7xZGdYmRncFZLeGtLRXbLVHgvm4Lo4tKD6QYzUmlJZvKuSsEwUj f3t+aHSH/7FL4pC+THWY5O820gx3vqZzClXvn8Q/8Rc0AzaQbDrjAmoebQF7zzqcVA0g J3L1MV04S0x1zk97w2C9joewDdhCArerPHNsJMh8mCJmkqgo5brIHY8EI+L1mvcCujln ag== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3skx9k053a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Aug 2023 01:37:28 +0000 Received: from m0353724.ppops.net (m0353724.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 37L1SgW0031226; Mon, 21 Aug 2023 01:37:28 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3skx9k052w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Aug 2023 01:37:28 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 37KNHMb8020760; Mon, 21 Aug 2023 01:37:27 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3sk9jk6u2e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Aug 2023 01:37:27 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 37L1bONu10552016 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 21 Aug 2023 01:37:24 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7E62F20049; Mon, 21 Aug 2023 01:37:24 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5B5922004B; Mon, 21 Aug 2023 01:37:22 +0000 (GMT) Received: from [9.197.232.239] (unknown [9.197.232.239]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 21 Aug 2023 01:37:22 +0000 (GMT) Message-ID: <5847e749-f7e1-d8cf-828a-9b39b46b84fa@linux.ibm.com> Date: Mon, 21 Aug 2023 09:37:21 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH-1, combine] Don't widen shift mode when target has rotate/mask instruction on original mode [PR93738] To: Jeff Law , Segher Boessenkool Cc: David , "Kewen.Lin" , Peter Bergner , gcc-patches References: <531959dd-1342-cbf1-054b-faf620907aea@linux.ibm.com> <514e6a6c-b357-f2ca-70ad-7af7cee6bfbe@gmail.com> <389f603d-ba15-ad1c-3c62-4ec34f9b545d@gmail.com> Content-Language: en-US From: HAO CHEN GUI In-Reply-To: <389f603d-ba15-ad1c-3c62-4ec34f9b545d@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ESWaM_m4U52huNXsFEXm0dlu7TwyJ6Af X-Proofpoint-ORIG-GUID: Ac3I49JcP6-arWvBmDFntEZ3FtedMe3R X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-20_15,2023-08-18_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 impostorscore=0 adultscore=0 clxscore=1015 mlxscore=0 bulkscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308210012 X-Spam-Status: No, score=-14.6 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Jeff, Thanks a lot for your comments. The widen shift mode is on i1/i2 before they're combined with i3 to newpat. The newpat matches rotate/mask pattern. The i1/i2 itself don't match rotate/mask pattern. I did an experiment to disable widen shift mode for lshiftrt. I tested it on powerpc/x86/aarch64. There is no regression occurred. I thought that the widen shift mode is helpful for newpat matching. But it seems not, at least no impact on powerpc/x86/aarch64. diff --git a/gcc/combine.cc b/gcc/combine.cc index 4bf867d74b0..0b9b115f9bb 100644 --- a/gcc/combine.cc +++ b/gcc/combine.cc @@ -10479,11 +10479,6 @@ try_widen_shift_mode (enum rtx_code code, rtx op, int count, return orig_mode; case LSHIFTRT: - /* Similarly here but with zero bits. */ - if (HWI_COMPUTABLE_MODE_P (mode) - && (nonzero_bits (op, mode) & ~GET_MODE_MASK (orig_mode)) == 0) - return mode; - /* We can also widen if the bits brought in will be masked off. This operation is performed in ORIG_MODE. */ if (outer_code == AND) Segher, Could you inform me what's the purpose of widen shift mode in simplify_shift_const? Does it definitely reduce the rtx cost or it helps match patterns? Thanks a lot. Thanks Gui Haochen 在 2023/8/5 7:32, Jeff Law 写道: > > > On 7/20/23 18:59, HAO CHEN GUI wrote: >> Hi Jeff, >> >> 在 2023/7/21 5:27, Jeff Law 写道: >>> Wouldn't it make more sense to just try rotate/mask in the original mode before trying a shift in a widened mode?  I'm not sure why we need a target hook here. >> >> There is no change to try rotate/mask with the original mode when >> expensive_optimizations is set. The subst widens the shift mode. > But we can add it before the attempt in the wider mode. > >> >>        if (flag_expensive_optimizations) >>          { >>            /* Pass pc_rtx so no substitutions are done, just >>               simplifications.  */ >>            if (i1) >>              { >>                subst_low_luid = DF_INSN_LUID (i1); >>                i1src = subst (i1src, pc_rtx, pc_rtx, 0, 0, 0); >>              } >> >>            subst_low_luid = DF_INSN_LUID (i2); >>            i2src = subst (i2src, pc_rtx, pc_rtx, 0, 0, 0); >>          } >> >> I don't know if the wider mode is helpful to other targets, so >> I added the target hook. > In this scenario we're often better off relying on rtx_costs (even with all its warts) rather than adding yet another target hook. > > I'd love to hear from Segher here to see if he's got other ideas. > > jeff