On Mon, Nov 28, 2022 at 6:33 AM HAO CHEN GUI via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hi,
>    Gentle ping this:
> https://gcc.gnu.org/pipermail/gcc-patches/2022-November/607083.html
> Thanks
> Gui Haochen
>
> 在 2022/11/23 10:54, HAO CHEN GUI 写道:
> > Hi,
> >   I want to enable "have_cbranchcc4" on rs6000. But not all combinations of
> > comparison codes and sub CC modes are benefited to generate cbranchcc4 insns
> > on rs6000. There is an predicate for operand0 of cbranchcc4 to bypass
> > some combinations. It gets assertion failure in prepare_cmp_insn. I think
> > we shouldn't suppose that all comparison codes and sub CC modes are 
> > supported
> > and throw an assertion failure in prepare_cmp_insn. It might check the
> > predicate and go to fail if the predicate can't be satisfied. This patch
> > changes the behavior of those codes.
> >
> >   Bootstrapped and tested on powerpc64-linux BE/LE and x86 with no 
> > regressions.
> > Is this okay for trunk? Any recommendations? Thanks a lot.

Since the function seems to be allowed to fail the patch looks
reasonable - still I wonder
what the "fallback" for a MODE_CC style compare-and-branch is?  There
are callers
of this function that do not seem to expect failure at least, some
suspiciously looking
like MODE_CC candiates.

Richard.

> >
> >
> > ChangeLog
> > 2022-11-23  Haochen Gui <guih...@linux.ibm.com>
> >
> > gcc/
> >       * optabs.cc (prepare_cmp_insn): Go to fail other than assert it when
> >       predicate check of "cbranchcc4" operand[0] fails.
> >
> > patch.diff
> > diff --git a/gcc/optabs.cc b/gcc/optabs.cc
> > index 165f8d1fa22..3ec8f6b17ba 100644
> > --- a/gcc/optabs.cc
> > +++ b/gcc/optabs.cc
> > @@ -4484,8 +4484,9 @@ 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));
> > +      gcc_assert (icode != CODE_FOR_nothing);
> > +      if (!insn_operand_matches (icode, 0, test))
> > +     goto fail;
> >        *ptest = test;
> >        return;
> >      }

Reply via email to