From patchwork Mon Jun 27 09:35:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 55431 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E1AEA386F0E2 for ; Mon, 27 Jun 2022 09:36:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E1AEA386F0E2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1656322561; bh=O5DfkAUSgb0BritnWz+kY2tzc0TSyc/xMyTW498k0P0=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=M7WnQVp+Qm6HFJgraHU/Sjn++cjlGUN+g7trrCRti2gmXrl7M1SuZ+MDJQAIrAAR9 KKZhiII+req5osoUpjCXkcnHL3XCIZgm24+4DaW7OGNYLh3nDTeSkcv1dwhlwfobPZ 7AbMpPw+cgWhprVoiP4Oq8Vz8Z0dLVOgUv/JjqkU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id ED8BC3841455 for ; Mon, 27 Jun 2022 09:35:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ED8BC3841455 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25R9L2AM023644; Mon, 27 Jun 2022 09:35:10 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3gy9ueg90q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Jun 2022 09:35:10 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 25R9LR6C024026; Mon, 27 Jun 2022 09:35:09 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3gy9ueg901-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Jun 2022 09:35:09 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 25R9YjMU024474; Mon, 27 Jun 2022 09:35:07 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03ams.nl.ibm.com with ESMTP id 3gwt08tmw1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Jun 2022 09:35:07 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25R9Z52l20119998 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 27 Jun 2022 09:35:05 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5FC804C046; Mon, 27 Jun 2022 09:35:05 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2AC0C4C040; Mon, 27 Jun 2022 09:35:04 +0000 (GMT) Received: from [9.200.41.46] (unknown [9.200.41.46]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 27 Jun 2022 09:35:03 +0000 (GMT) Message-ID: <91690387-7e70-3e5c-9a20-00863dc393e3@linux.ibm.com> Date: Mon, 27 Jun 2022 17:35:03 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Content-Language: en-US To: GCC Patches Subject: [PATCH] rs6000: Simplify *rotl3_insert_4 by removing DImode X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 0zy2yhpctaIlspYeCb6ElPH8qbDycEXY X-Proofpoint-ORIG-GUID: HCeQIYATjKhr5yaxIu2yZnBh8ScimX1U 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-06-27_06,2022-06-24_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 suspectscore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 spamscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206270041 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, 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-Patchwork-Original-From: "Kewen.Lin via Gcc-patches" From: "Kewen.Lin" Reply-To: "Kewen.Lin" Cc: David Edelsohn , Segher Boessenkool Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi, define_insn *rotl3_insert_4 use mode iterator GPR which consists of SImode and conditional DImode, but the condition of this define_insn requires the mode should be SImode. By further checking, it's found that the rldimi instruction can not be used for this pattern since the required mask can not be represented correctly. We can have the fixed mask end 31 with rlwimi, but can not have the fixed mask end with rldimi as it has to be (63 - SH) always. So this patch simplifies the define_insn to use SImode only. Tested on powerpc64-linux-gnu P8 and powerpc64le-linux-gnu P9 and P10. Is it ok for trunk? BR, Kewen ----- gcc/ChangeLog: * config/rs6000/rs6000.md (*rotl3_insert_4): Replace mode iterator GPR with SImode, adjust the condition and output template, rename to ... (*rotlsi3_insert_4): ... this. --- gcc/config/rs6000/rs6000.md | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) -- 2.32.0 diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index c55ee7e171a..aef88e94576 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -4206,23 +4206,18 @@ (define_split operands[4] = GEN_INT ((HOST_WIDE_INT_1U << INTVAL (operands[2])) - 1); }) -(define_insn "*rotl3_insert_4" - [(set (match_operand:GPR 0 "gpc_reg_operand" "=r") - (ior:GPR (and:GPR (match_operand:GPR 3 "gpc_reg_operand" "0") - (match_operand:GPR 4 "const_int_operand" "n")) - (lshiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "r") +; It's unable to extend this define_insn for DImode, because the +; corresponding hardware instruction for DImode is rldimi, which only has +; four operands and the end of mask is always (63 - SH) rather than 63 +; that is required for this pattern. +(define_insn "*rotlsi3_insert_4" + [(set (match_operand:SI 0 "gpc_reg_operand" "=r") + (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "0") + (match_operand:SI 4 "const_int_operand" "n")) + (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r") (match_operand:SI 2 "const_int_operand" "n"))))] - "mode == SImode && - GET_MODE_PRECISION (mode) - == INTVAL (operands[2]) + exact_log2 (-UINTVAL (operands[4]))" -{ - operands[2] = GEN_INT (GET_MODE_PRECISION (mode) - - INTVAL (operands[2])); - if (mode == SImode) - return "rlwimi %0,%1,%h2,32-%h2,31"; - else - return "rldimi %0,%1,%H2,64-%H2"; -} + "INTVAL (operands[2]) + exact_log2 (-UINTVAL (operands[4])) == 32" + "rlwimi %0,%1,32-%h2,%h2,31" [(set_attr "type" "insert")]) (define_insn "*rotlsi3_insert_5"