From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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 (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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : to : cc : from : subject : content-type : content-transfer-encoding; s=pp1; bh=JsyR+s8bHlZzilDeyA1S1Z9MEGZ54f1aBr+HsT+Aly8=; b=tij3fMRQSEwL8Ohs3RsTBZtqlQYAq8RX80SkjRn6+DEsjD+Cl6zzdI5oSYtSB9UrMOnF TliTmZHosaWXyn+RHJvGuDvKCtaxrnvVtrSdIe4jfHlk/DeBS6CckLLgVPzACqLZf8o6 SWkWpASbUzv3T6HaYCASkyz897odbBMRoh5GGChdlDnJ4rCQx0+H1L7Tl4qPIKL6cXJd ndBjKZRZGADrrusqT2QS5lttUSbUvKw8BEUZUCOKL4ww0h4Vj9wwKquM0CUv/VEqs5wV ZS7lZi285TOLovZ7N2jQp9ue+TU9wSXBhRQilMki8QF+nl+W+loTaKZg2X1zEniPokN1 Mg== 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 From: HAO CHEN GUI Subject: [PATCHv2, rs6000] Enable have_cbranchcc4 on rs6000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 List-Id: 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)); +}