From: Haochen Gui Date: Thu, 8 Dec 2022 05:22:29 +0000 (+0800) Subject: optabs: make prepare_cmp_insn goto fail when cbranchcc4 checks unsatisfied X-Git-Tag: basepoints/gcc-14~2580 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99cce60d0b8f3c3a77be8e1bb716f3e2fee37d46;p=thirdparty%2Fgcc.git 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 --git a/gcc/optabs.cc b/gcc/optabs.cc index 262a37f9b3f0..2ffd455202d3 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);