From patchwork Tue Dec 6 05:44:49 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: 30086 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2646797wrr; Mon, 5 Dec 2022 21:45:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf6gycGb3K8tmmojhs16wyZdrccHf6I0NTax/BAwqExTNO+QMVebFHhfyO9dFl1M/F/Qo/+J X-Received: by 2002:a17:907:874f:b0:7b5:e91:adf9 with SMTP id qo15-20020a170907874f00b007b50e91adf9mr46090260ejc.277.1670305541724; Mon, 05 Dec 2022 21:45:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670305541; cv=none; d=google.com; s=arc-20160816; b=W5RX0R1dw2ITumX8UCuWKyiCpjLkFP9ZPxZ7pNuXburSDPufIYQ3SqjzjT3NI9Oz9I r9MuHvZ8pRk58jcxdJHwY8Oae79Lb4Dx7eQta4xHgV6Olbo2ETKM08dHc3IqqUowPcKE b/Z4L9+gXLWhQTdaSHEcwYao/vz+WdOWyEBL5P42rK6kaTxBJ7w5UoPd3W3bJYNbQ6hU iEatI9JJiG5QNR11stjtADcgZRx/98bPDjRh1b4UQI4K/u43oSBnbeRc0OGOt03IUzTF g9b9dw9p9BhBZlkrzCtljJ8xNfedN7vpvx3v5W8iSj9lkn9XYTtce4EXLLPi6CBl9Zfm JPHg== 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:mime-version :content-transfer-encoding:subject:cc:to:content-language:user-agent :date:message-id:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=MmfwlRtPLecEOt5X94XWUCDXfTmtEwyJEv98n4aAXKM=; b=k1QDI3Fb/tVoUuUWG5YU48rM1cySCHfeXxtIzveB+No7DV6TTDUNLMtIisK0tpmMDw 0yhWCt+zIx98PiCPPcJFh+Pl6qfvbbnIaaoXW2BbBvgraSRpKMz0Un5lq/fn4yORpyaQ atn472Fxi1cUiJF62g4tw45Bv5/UuvgkBSHyoLZ10JEBwSblnJzKj+3MGj1LuswuT0rS +XD5mnROiC4uGT/4yxyzROaZGcJJL/Hsr6WppYLUOdz1LLyxYbvpAY7xq/NaVWvorAWr MuBlIQFhTt9gHSDyLv4cx0tbj90d4UUEkbZQwT4q7u+FfLhwaiHHauwUVYUjDHK02rAG z2Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=NQWGyv5q; 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id w17-20020a056402071100b0045d4a88c735si1150400edx.220.2022.12.05.21.45.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 21:45:41 -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=NQWGyv5q; 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 C7464395445F for ; Tue, 6 Dec 2022 05:45:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C7464395445F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670305540; bh=MmfwlRtPLecEOt5X94XWUCDXfTmtEwyJEv98n4aAXKM=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=NQWGyv5ql1SJoR0x4etHJ2mt6KStjmMJ6kf1Yea5sm/Dxj3P5FGRqs9XqM0O9UM0U Qm0V93QjGtZK6giw2ESwIFOUR0mUxGsy8aVD1X2DJTcgDfJDHH/UjfBfe2HPNUlRnP 9IKLky9SGeLaZ3LODuxlohiHZND92KLVlqiZKedo= 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 B303A395443D for ; Tue, 6 Dec 2022 05:44:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B303A395443D Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B63ZhAI002457; Tue, 6 Dec 2022 05:44:58 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3m9wyba9ka-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Dec 2022 05:44:58 +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 2B65ZXHZ003493; Tue, 6 Dec 2022 05:44:57 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3m9wyba9js-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Dec 2022 05:44:57 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 2B5K5FOW010873; Tue, 6 Dec 2022 05:44:55 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3m9kvb8t1s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Dec 2022 05:44:55 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com ([9.149.105.160]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2B65iq0j19530148 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 6 Dec 2022 05:44:52 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0D329A405B; Tue, 6 Dec 2022 05:44:52 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8B361A405C; Tue, 6 Dec 2022 05:44:49 +0000 (GMT) Received: from [9.171.13.250] (unknown [9.171.13.250]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 6 Dec 2022 05:44:48 +0000 (GMT) Message-ID: Date: Tue, 6 Dec 2022 13:44:49 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Content-Language: en-US To: gcc-patches Cc: Segher Boessenkool , David , "Kewen.Lin" , Peter Bergner Subject: [PATCH v3, rs6000] Enable have_cbranchcc4 on rs6000 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Qvjk8TzUhszNQ7yQmNUFv7Tv-_AUdWFi X-Proofpoint-ORIG-GUID: q3C94hEaZ2h2rZFnMoK5dUXcljf_ysdR X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-06_03,2022-12-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 priorityscore=1501 mlxscore=0 bulkscore=0 clxscore=1015 adultscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212060044 X-Spam-Status: No, score=-12.1 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?1751442304044780786?= X-GMAIL-MSGID: =?utf-8?q?1751442304044780786?= Hi, This patch enables "have_cbranchcc4" on rs6000 by defining a "cbranchcc4" expander. "have_cbrnachcc4" is a flag in ifcvt.cc to indicate if branch by CC bits is invalid or not. With this flag enabled, some branches can be optimized to conditional moves. The patch relies on the former patch which is under review. https://gcc.gnu.org/pipermail/gcc-patches/2022-December/607810.html Bootstrapped and tested on powerpc64-linux BE and LE with no regressions. Is this okay for trunk? Any recommendations? Thanks a lot. Thanks Gui Haochen ChangeLog 2022-12-06 Haochen Gui gcc/ * config/rs6000/rs6000.md (cbranchcc4): New expander. gcc/testsuite * gcc.target/powerpc/cbranchcc4.c: New. * gcc.target/powerpc/cbranchcc4-1.c: New. patch.diff diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index e9e5cd1e54d..d7ddd96cc70 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -11932,6 +11932,16 @@ (define_expand "cbranch4" DONE; }) +(define_expand "cbranchcc4" + [(set (pc) + (if_then_else (match_operator 0 "branch_comparison_operator" + [(match_operand 1 "cc_reg_operand") + (match_operand 2 "zero_constant")]) + (label_ref (match_operand 3)) + (pc)))] + "" + "") + (define_expand "cstore4_signed" [(use (match_operator 1 "signed_comparison_operator" [(match_operand:P 2 "gpc_reg_operand") diff --git a/gcc/testsuite/gcc.target/powerpc/cbranchcc4-1.c b/gcc/testsuite/gcc.target/powerpc/cbranchcc4-1.c new file mode 100644 index 00000000000..3c8286bf091 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/cbranchcc4-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" */ + +/* This case should be successfully compiled after cbranchcc4 is enabled. It + generates a "*cbranch_2insn" insn which makes predicate check of cbranchcc4 + failed and returns a NULL rtx from prepare_cmp_insn. */ + +int foo (double d) +{ + if (d == 0.0) + return 0; + + d = ((d) >= 0 ? (d) : -(d)); + + if (d < 1.0) + return 1; +} 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)); +}