From patchwork Thu Nov 17 06:39:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: HAO CHEN GUI X-Patchwork-Id: 21460 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp244440wrr; Wed, 16 Nov 2022 22:40:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf7tlnWBplUq3H+O4tDMwZ8pldbLTo+BSJaMS3F8YAT55zdOShWrcEcyg18x47+98V5aZJTk X-Received: by 2002:aa7:d718:0:b0:467:6ffe:e94c with SMTP id t24-20020aa7d718000000b004676ffee94cmr908471edq.417.1668667217678; Wed, 16 Nov 2022 22:40:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668667217; cv=none; d=google.com; s=arc-20160816; b=Xs8UYAy+WB2pya4J41++h2Tv97oD/3d0/YSYGl0Md4/fvAfsnwMI2dRNEQV3ju0WnK dJh9UnYzOJkzJxem4LS7bA1PSKiiCzkFXw/4rxipykhNg5ef1EXmUPxr4FPiTezN0/uD hnHnc83iUh7O/mxa3vsaFKZ6XY0qQDxgv+ERho6dk+rXjBWcvMwapwbXJszPVLr0uwtH d9g6CbAnK5IVnyGCkEBiJ9TQWz9jo4wAqNZxW3Tx6ZcEeet61eHjw4U2XFqbZ6wEDW3P 3HR6gnTuH70DuNtC6SISlDqjz8nGm5zNWFA+Fookg3EgpQW7SP6hDz1RPkE7RAb7oJ2y IrzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:subject:cc:to:user-agent:mime-version :date:message-id:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=JsyR+s8bHlZzilDeyA1S1Z9MEGZ54f1aBr+HsT+Aly8=; b=zh71wtQFzb7hriJIfQ7K2YgtFTgwWF8WP4lAxB4PcNGJfsGSdzpykdoWcdG8dBH9X/ /TvVs6vlXk6Pw4GYjn/tVUbpjl6K/E8P5Vtvv3xmGzBEepw9ReV2N70KegOvmzL8vDpc Mgm1PwkGGpQwll+iN9UerimQlVO7dLAWjfduEXKfqh8tWgrzAi1V13Zm0oM82osm4n5D 6ahJIjFsVmhhyw9McIU885/wJTtrZWU+iAO9+bXiQH1jFzHPn9KP551vTBIqd1/XIdRW kF8o+7b3JYQSLWAX1KCO0s/Q4R2JJCpXTUzeE0A4+Cw7DDTiSU177ip540xatErzK3HB RJiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="d1Qc3Z/G"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id z12-20020a05640240cc00b0046154f0f866si256995edb.159.2022.11.16.22.40.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 22:40:17 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="d1Qc3Z/G"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A120F3894C24 for ; Thu, 17 Nov 2022 06:40:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A120F3894C24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668667216; bh=JsyR+s8bHlZzilDeyA1S1Z9MEGZ54f1aBr+HsT+Aly8=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=d1Qc3Z/GFED5YJQ5T63IH3hiX/EhD+NKHFCSL3zQVijR/CCO8pKx8kZsLiO/RCrL4 /wnCp+SSTUlukEVKHWFwX0Kjz4Y0XaYTQlvhosQrVmmCGMZjJA0Pbp/WdqPDuHRJxe PWHIlFwzN53PxeZN0Q+fEZo13PqVGrK4hGFvPxt0= 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 241B4382E514 for ; Thu, 17 Nov 2022 06:39:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 241B4382E514 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AH62NCm018792; Thu, 17 Nov 2022 06:39:29 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kwfb2h16n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 17 Nov 2022 06:39:29 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AH6OYaI022746; Thu, 17 Nov 2022 06:39:28 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 3kwfb2h15r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 17 Nov 2022 06:39:28 +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 2AH6aeuD017176; Thu, 17 Nov 2022 06:39:26 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03ams.nl.ibm.com with ESMTP id 3kt348y41f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 17 Nov 2022 06:39:26 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AH6dNoC38928816 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Nov 2022 06:39:23 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8C16011C04C; Thu, 17 Nov 2022 06:39:23 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 09BCB11C04A; Thu, 17 Nov 2022 06:39:22 +0000 (GMT) Received: from [9.200.144.161] (unknown [9.200.144.161]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 17 Nov 2022 06:39:21 +0000 (GMT) Message-ID: <438c6628-0b9c-e5d0-e198-2fd6edd16a93@linux.ibm.com> Date: Thu, 17 Nov 2022 14:39:20 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 To: gcc-patches Cc: Segher Boessenkool , David , "Kewen.Lin" , Peter Bergner Subject: [PATCHv2, rs6000] Enable have_cbranchcc4 on rs6000 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 6155Jr_CDWIr8Z-Zkdjk0XLDVzIQR6Bf X-Proofpoint-ORIG-GUID: Lt1VIEoMFacZA_v1ov-urZWj4-G3rhaK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-17_02,2022-11-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 adultscore=0 spamscore=0 phishscore=0 priorityscore=1501 suspectscore=0 clxscore=1011 bulkscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211170045 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_MSPIKE_H2, 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 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: HAO CHEN GUI via Gcc-patches From: HAO CHEN GUI Reply-To: HAO CHEN GUI Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749724396274683141?= X-GMAIL-MSGID: =?utf-8?q?1749724396274683141?= Hi, The patch enables have_cbrnachcc4 which is a flag in ifcvt.cc to indicate if branch by CC bits is invalid or not. The new expand pattern "cbranchcc4" is created which intend to match the pattern defined in "*cbranch", "*cbranch_2insn" and "*creturn". The operand sequence in "cbranchcc4" is inline with the definition in gccint. And the operand sequence doesn't matter in pattern matching. So I think it should work. Compared to last version, one new predicate and one new expander are created. Bootstrapped and tested on powerpc64-linux BE and LE with no regressions. Is this okay for trunk? Any recommendations? Thanks a lot. ChangeLog 2022-11-17 Haochen Gui gcc/ * config/rs6000/predicates.md (all_branch_comparison_operator): New, and includes operators in branch_comparison_operator and extra_insn_branch_comparison_operator. * config/rs6000/rs6000.md (cbranchcc4): New expand pattern. gcc/testsuite/ * gcc.target/powerpc/cbranchcc4.c: New. patch.diff diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md index b1fcc69bb60..843b6f39b84 100644 --- a/gcc/config/rs6000/predicates.md +++ b/gcc/config/rs6000/predicates.md @@ -1308,6 +1308,7 @@ (define_special_predicate "equality_operator" ;; Return 1 if OP is a comparison operation that is valid for a branch ;; instruction. We check the opcode against the mode of the CC value. + ;; validate_condition_mode is an assertion. (define_predicate "branch_comparison_operator" (and (match_operand 0 "comparison_operator") @@ -1331,6 +1332,11 @@ (define_predicate "extra_insn_branch_comparison_operator" GET_MODE (XEXP (op, 0))), 1"))) +;; Return 1 if OP is a comparison operation that is valid for a branch. +(define_predicate "all_branch_comparison_operator" + (ior (match_operand 0 "branch_comparison_operator") + (match_operand 0 "extra_insn_branch_comparison_operator"))) + ;; Return 1 if OP is an unsigned comparison operator. (define_predicate "unsigned_comparison_operator" (match_code "ltu,gtu,leu,geu")) diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index e9e5cd1e54d..7b7d747a85d 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -13067,6 +13067,16 @@ (define_insn_and_split "*_cc" ;; Conditional branches. ;; These either are a single bc insn, or a bc around a b. +(define_expand "cbranchcc4" + [(set (pc) + (if_then_else (match_operator 0 "all_branch_comparison_operator" + [(match_operand 1 "cc_reg_operand") + (match_operand 2 "zero_constant")]) + (label_ref (match_operand 3)) + (pc)))] + "" + "") + (define_insn "*cbranch" [(set (pc) (if_then_else (match_operator 1 "branch_comparison_operator" diff --git a/gcc/testsuite/gcc.target/powerpc/cbranchcc4.c b/gcc/testsuite/gcc.target/powerpc/cbranchcc4.c new file mode 100644 index 00000000000..528ba1a878d --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/cbranchcc4.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-rtl-ce1" } */ +/* { dg-final { scan-rtl-dump "noce_try_store_flag_constants" "ce1" } } */ + +/* The inner branch should be detected by ifcvt then be converted to a setcc + with a plus by noce_try_store_flag_constants. */ + +int test (unsigned int a, unsigned int b) +{ + return (a < b ? 0 : (a > b ? 2 : 1)); +}