From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7808) id 1207C38717F6; Tue, 13 Dec 2022 08:33:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1207C38717F6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670920434; bh=TASrekPbW0l53dYw9y7uisD+uKaAsFIHjs3rfCil2Zg=; h=From:To:Subject:Date:From; b=n6Tnh2bopk8/xC79Bbzo4mj+l8nZ5kzHDLGz/zVKUy+HzDUwkD9O53m5+sDy7Yl0V niLIAgTu6gQLVOEdIxT1B+E7oYcYuGCz4y+qOx7Jy7ba52kz9oLi2rkGObHXOB/ASV VhmnYKqlly0CMxjoNyUj2144IhGpcOxhoHskxU5g= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: HaoChen Gui To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4627] optabs: make prepare_cmp_insn goto fail when cbranchcc4 checks unsatisfied X-Act-Checkin: gcc X-Git-Author: Haochen Gui X-Git-Refname: refs/heads/master X-Git-Oldrev: 1728c537b4f697e2a4b4eba0b0c70165f2a02840 X-Git-Newrev: 99cce60d0b8f3c3a77be8e1bb716f3e2fee37d46 Message-Id: <20221213083354.1207C38717F6@sourceware.org> Date: Tue, 13 Dec 2022 08:33:53 +0000 (GMT) List-Id: https://gcc.gnu.org/g:99cce60d0b8f3c3a77be8e1bb716f3e2fee37d46 commit r13-4627-g99cce60d0b8f3c3a77be8e1bb716f3e2fee37d46 Author: Haochen Gui Date: Thu Dec 8 13:22:29 2022 +0800 optabs: make prepare_cmp_insn goto fail when cbranchcc4 checks unsatisfied prepare_cmp_insn is a help function to generate comparison rtx. It should not assume that cbranchcc4 exists and all sub-CC modes are supported on a target. When the check fails, it could go to fail and return a NULL rtx as its callers check the return value for CCmode. The test case (gcc.target/powerpc/cbranchcc4-1.c) which covers failure path will be committed with an rs6000 specific patch. 2022-12-05 Haochen Gui 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. Diff: --- gcc/optabs.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gcc/optabs.cc b/gcc/optabs.cc index 262a37f9b3f..2ffd455202d 100644 --- a/gcc/optabs.cc +++ b/gcc/optabs.cc @@ -4491,10 +4491,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; } test = gen_rtx_fmt_ee (comparison, VOIDmode, x, y);