[v2] Return a NULL rtx when targets don't support cbranchcc4 or predicate check fails in prepare_cmp_insn
Message ID | 905c34de-6333-1021-05e6-942922918b18@linux.ibm.com |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2042204wrr; Sun, 4 Dec 2022 19:08:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Leuse7dmG9SsHuvHFI5yWSenjPY8WdhYeo4aZJUJkjXzwWBa5ANl0MJvlW+fplfQn5rrY X-Received: by 2002:a17:906:cc8f:b0:78b:8ce7:fe3c with SMTP id oq15-20020a170906cc8f00b0078b8ce7fe3cmr68008084ejb.557.1670209729379; Sun, 04 Dec 2022 19:08:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670209729; cv=none; d=google.com; s=arc-20160816; b=LKxlKGkTD9akOdlTxA/wMXYWr1AMKnAoa10BQ236ACTkcgZRkoYB2c2oJI5sK5IK1M 5iw8tLnfUhFWQnBgmsFSz9m4y9HpZhOL9qx7h5hOLLudQanB/VzGr86v/VQEn9NWFaL7 HWFC5kz/TsP8+RhZ6vLcXbGJQLWxgtLs1YL7vMb7ITeoa2WTq+xnZqDUH1uh2JamQulc YSxULdvBQO1ylxDdAld+gye5nCYOwz6eKmfqD5S7YDUBx0/lK5IXsp/3NSzxhLdK30Lx FEugiwHfzJdKmA76Fxm8MQq9KqOBnj7I3GC7Br8dMQ0KD7ioTqWmy6kfZiXmLIns2Csz AjPw== 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:content-language:user-agent :mime-version:date:message-id:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=D54bj+5LWZGa52Vmi/sxaBkF8iag3nMB1co4WuyY2A0=; b=M/oT7aCffa3BWFDWIYgkRIoAYdyoe3Ht1xvFhajvtl3+xkvI/A5pLQm3+e5glNLw5R PPxuVY7y5Oie2OFn717pMNoNG/ctRyb/Q/gEdaxyGOObiR2XK6W7MeZPb9emjcuUZ/vx 2zpWwH9mX5dXotYYIpIrw2fAgw04rKH0EZM1gX165tGvA15k9dMf8Yzsa7a/pCxqo2CC 4Zvyy6iTyP6JZBLEgSBEwCT3ceodOjXkiosnsFQkX/F9rVXA+nwpLMh+yZpkmqTR+HMW GdK1e93MzHuDViissvCgWz901uTZoLep1bCv4GhGQpqB1xTWsEfvy9i8T+yjHz+zAcIy S6jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=iT8dUB6R; 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 sh36-20020a1709076ea400b007aa1aa8ca57si12084736ejc.859.2022.12.04.19.08.49 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Dec 2022 19:08:49 -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=iT8dUB6R; 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 2BA183883029 for <ouuuleilei@gmail.com>; Mon, 5 Dec 2022 03:08:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2BA183883029 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670209728; bh=D54bj+5LWZGa52Vmi/sxaBkF8iag3nMB1co4WuyY2A0=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=iT8dUB6RGLkAhbGyHi4UQlf0OyKwWpHEsjMKbYt0cNQzuCzjAzdszYDfyxPUxRTvp nZnpOE/T5raHaeB+uk6ji2LNfs87QpQv2GUDxadueA6UOhFBHLcFFxoUyUD+A+Pxkm +2nlTLHmougMzFolvhDaJoIZzXTRErNOiHmEcjbA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 8FEC5382EF36 for <gcc-patches@gcc.gnu.org>; Mon, 5 Dec 2022 03:08:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8FEC5382EF36 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B51hftN018982; Mon, 5 Dec 2022 03:08:04 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m8g8snyqq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Dec 2022 03:08:04 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2B52ZYLO032375; Mon, 5 Dec 2022 03:08:03 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m8g8snyq6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Dec 2022 03:08:03 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2B536Gt0026558; Mon, 5 Dec 2022 03:08:01 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma04ams.nl.ibm.com with ESMTP id 3m7x38t4cq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Dec 2022 03:08:01 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2B537wh026149510 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 5 Dec 2022 03:07:58 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EC91442041; Mon, 5 Dec 2022 03:07:57 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 706304203F; Mon, 5 Dec 2022 03:07:55 +0000 (GMT) Received: from [9.179.20.246] (unknown [9.179.20.246]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 5 Dec 2022 03:07:55 +0000 (GMT) Message-ID: <905c34de-6333-1021-05e6-942922918b18@linux.ibm.com> Date: Mon, 5 Dec 2022 11:07:56 +0800 MIME-Version: 1.0 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 <gcc-patches@gcc.gnu.org> Cc: Segher Boessenkool <segher@kernel.crashing.org>, David <dje.gcc@gmail.com>, "Kewen.Lin" <linkw@linux.ibm.com>, Richard Biener <richard.guenther@gmail.com>, Peter Bergner <bergner@linux.ibm.com> Subject: [PATCH v2] Return a NULL rtx when targets don't support cbranchcc4 or predicate check fails in prepare_cmp_insn Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 5N6utEtKE1lo-uBatAgDLqPIMFeGk7D5 X-Proofpoint-GUID: nM3svOc3fkOkOC5PkjYN3sOIlBJO8CwJ 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-05_01,2022-12-01_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212050023 X-Spam-Status: No, score=-12.5 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 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: HAO CHEN GUI via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: HAO CHEN GUI <guihaoc@linux.ibm.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751341836879137856?= X-GMAIL-MSGID: =?utf-8?q?1751341836879137856?= |
Series |
[v2] Return a NULL rtx when targets don't support cbranchcc4 or predicate check fails in prepare_cmp_insn
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
HAO CHEN GUI
Dec. 5, 2022, 3:07 a.m. UTC
Hi, It gets an assertion failure when targers don't support cbranchcc4 or predicate check fails in prepare_cmp_insn. prepare_cmp_insn is a help function to generate compare rtx, so it should not assume that cbranchcc4 is existing or all sub-CC modes are supported on one target. I think it should return the NULL rtx when cbranchcc4 is not supported or predicate check fails, as its callers already check if the return value is null or not for CC mode. This patch just does the change. Bootstrapped and tested on powerpc64-linux BE/LE and x86 with no regressions. Is this okay for trunk? Any recommendations? Thanks a lot. ChangeLog 2022-12-05 Haochen Gui <guihaoc@linux.ibm.com> gcc/ * optabs.cc (prepare_cmp_insn): Return a NULL rtx other than assertion failure when targets don't have cbranch optab or predicate check fails. patch.diff
Comments
On Mon, Dec 5, 2022 at 4:08 AM HAO CHEN GUI <guihaoc@linux.ibm.com> wrote: > > Hi, > It gets an assertion failure when targers don't support cbranchcc4 or > predicate check fails in prepare_cmp_insn. prepare_cmp_insn is a help > function to generate compare rtx, so it should not assume that cbranchcc4 > is existing or all sub-CC modes are supported on one target. I think it > should return the NULL rtx when cbranchcc4 is not supported or predicate check > fails, as its callers already check if the return value is null or not for CC > mode. This patch just does the change. > > Bootstrapped and tested on powerpc64-linux BE/LE and x86 with no regressions. > Is this okay for trunk? Any recommendations? Thanks a lot. I wonder if you have a testcase you can add showing this change is worthwhile and fixes a bug? OK. Thanks, Richard. > > ChangeLog > 2022-12-05 Haochen Gui <guihaoc@linux.ibm.com> > > gcc/ > * optabs.cc (prepare_cmp_insn): Return a NULL rtx other than assertion > failure when targets don't have cbranch optab or predicate check > fails. > > patch.diff > diff --git a/gcc/optabs.cc b/gcc/optabs.cc > index 165f8d1fa22..f6d3242479b 100644 > --- a/gcc/optabs.cc > +++ b/gcc/optabs.cc > @@ -4484,10 +4484,14 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx_code comparison, rtx size, > { > enum insn_code icode = optab_handler (cbranch_optab, CCmode); > test = gen_rtx_fmt_ee (comparison, VOIDmode, x, y); > - gcc_assert (icode != CODE_FOR_nothing > - && insn_operand_matches (icode, 0, test)); > - *ptest = test; > - return; > + if (icode != CODE_FOR_nothing > + && insn_operand_matches (icode, 0, test)) > + { > + *ptest = test; > + return; > + } > + else > + goto fail; > } > > mclass = GET_MODE_CLASS (mode);
Hi Richard, 在 2022/12/5 15:31, Richard Biener 写道: > I wonder if you have a testcase you can add showing this change is > worthwhile and > fixes a bug? I want to enable cbranchcc4 on rs6000. But not all sub CCmode is supported on rs6000. So the predicate check(assert) fails and it hits ICE. I drafted two patches. This one is for the generic code, and another is for rs6000. If this one is committed, cbranchcc4 can be enabled on rs6000. Then I can create a testcase and let the predicate check fail. Right now I can't write a testcase for it as it never reaches the failure path. Thanks a lot Gui Haochen
On Mon, Dec 5, 2022 at 9:43 AM HAO CHEN GUI <guihaoc@linux.ibm.com> wrote: > > Hi Richard, > > 在 2022/12/5 15:31, Richard Biener 写道: > > I wonder if you have a testcase you can add showing this change is > > worthwhile and > > fixes a bug? > > I want to enable cbranchcc4 on rs6000. But not all sub CCmode is > supported on rs6000. So the predicate check(assert) fails and it hits > ICE. I drafted two patches. This one is for the generic code, and > another is for rs6000. If this one is committed, cbranchcc4 can be > enabled on rs6000. Then I can create a testcase and let the predicate > check fail. Right now I can't write a testcase for it as it never > reaches the failure path. Fair enough. > Thanks a lot > Gui Haochen >
diff --git a/gcc/optabs.cc b/gcc/optabs.cc index 165f8d1fa22..f6d3242479b 100644 --- a/gcc/optabs.cc +++ b/gcc/optabs.cc @@ -4484,10 +4484,14 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx_code comparison, rtx size, { enum insn_code icode = optab_handler (cbranch_optab, CCmode); test = gen_rtx_fmt_ee (comparison, VOIDmode, x, y); - gcc_assert (icode != CODE_FOR_nothing - && insn_operand_matches (icode, 0, test)); - *ptest = test; - return; + if (icode != CODE_FOR_nothing + && insn_operand_matches (icode, 0, test)) + { + *ptest = test; + return; + } + else + goto fail; } mclass = GET_MODE_CLASS (mode);