From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 402E23858D28 for ; Fri, 12 Aug 2022 08:09:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 402E23858D28 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27C7mTfm018956; Fri, 12 Aug 2022 08:09:42 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hwjss8wuj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Aug 2022 08:09:41 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 27C7oHWq025697; Fri, 12 Aug 2022 08:09:32 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hwjss8w0v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Aug 2022 08:09:32 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 27C7Z9P4025876; Fri, 12 Aug 2022 08:04:12 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06ams.nl.ibm.com with ESMTP id 3huwvf2y25-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Aug 2022 08:04:11 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 27C848MO34996546 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Aug 2022 08:04:08 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A9453A4051; Fri, 12 Aug 2022 08:04:08 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0F0DBA404D; Fri, 12 Aug 2022 08:04:07 +0000 (GMT) Received: from [9.197.246.45] (unknown [9.197.246.45]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 12 Aug 2022 08:04:06 +0000 (GMT) Message-ID: <6d990448-01c2-bb5f-c6ed-6cbbf88dc104@linux.ibm.com> Date: Fri, 12 Aug 2022 16:04:05 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH v3] Modify combine pattern by a pseudo AND with its nonzero bits [PR93453] Content-Language: en-US To: Segher Boessenkool Cc: gcc-patches , David , "Kewen.Lin" , Peter Bergner References: <20220810173852.GC25951@gate.crashing.org> <20220811174031.GH25951@gate.crashing.org> From: HAO CHEN GUI In-Reply-To: <20220811174031.GH25951@gate.crashing.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 3ot7RIpcJ9JV3ANT-w89bhrkST1XcmIl X-Proofpoint-ORIG-GUID: 6YDcZ-7cRfFjAFIvwRm-zDaXNScfoHFX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-12_04,2022-08-11_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=912 spamscore=0 priorityscore=1501 lowpriorityscore=0 mlxscore=0 malwarescore=0 clxscore=1015 bulkscore=0 adultscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208120020 X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Aug 2022 08:09:46 -0000 Hi Segher, On 12/8/2022 上午 1:40, Segher Boessenkool wrote: > Yes, but combine will use splitters as well. Combine pass invokes combine_split_insns for 3-insn combine. If we want to do the split for 2-insn combine (like the test case in PR), we have to add a special case? > > You can use nonzero_bits in the split condition (the second condition in > a define_split, or the sole condition in a define_split) just fine, as > long as the replacement RTL does not rely on the nonzero_bits itself. > You cannot use it in the insn condition (the first condition in a > define_insn_and_split, or the one condition in a define_insn) because > that RTL will survive past combine, and then nonzero_bits can have bits > cleared that were set before (that were determined to be always zero > during combine, but that knowledge is gone later). I tried to add a define_insn_and split pattern in rs6000.md, just like the following code. The nonzero_bits is used in insn condition (for combine) and no condition for the split. I can't set nonzero_bits in split condition as it never matches and cause ICE then. I am not sure if it is safe. If such an insn doesn't stem from the combine, there is no guarantee that the nonzero_bits condition matches. (define_insn_and_split "*test" [(set (match_operand:GPR 0 "gpc_reg_operand") (plus_ior_xor:GPR (ashift:GPR (match_operand:GPR 1 "gpc_reg_operand") (match_operand:SI 2 "const_int_operand")) (match_operand:GPR 3 "gpc_reg_operand")))] "nonzero_bits (operands[3], mode) < HOST_WIDE_INT_1U << INTVAL (operands[2])" "#" "" [(set (match_dup 0) (ior:GPR (and:GPR (match_dup 3) (match_dup 4)) (ashift:GPR (match_dup 1) (match_dup 2))))] { operands[4] = GEN_INT ((HOST_WIDE_INT_1U << INTVAL (operands[2])) - 1); }) Thanks Gui Haochen