On Fri, 17 Apr 2020, Jakub Jelinek wrote:

> On Fri, Apr 17, 2020 at 09:24:34AM +0200, Richard Biener wrote:
> > --- a/gcc/optabs.c
> > +++ b/gcc/optabs.c
> > @@ -1050,7 +1050,7 @@ expand_binop_directly (enum insn_code icode, 
> > machine_mode mode, optab binoptab,
> >    commutative_p = commutative_optab_p (binoptab);
> >    if (commutative_p
> >        && GET_MODE (xop0) != xmode0 && GET_MODE (xop1) != xmode1
> > -      && GET_MODE (xop0) == xmode1 && GET_MODE (xop1) == xmode1)
> > +      && GET_MODE (xop0) == xmode1 && GET_MODE (xop1) == xmode0)
> 
> Do we need 4 comparisons for that?  Wouldn't
>   if (commutative_p
>       && xmode0 != xmode1
>       && GET_MODE (xop0) == xmode1
>       && GET_MODE (xop1) == xmode0)
>     std::swap (xop0, xop1);
> be more readable and shorter?

Not sure - xmode[01] are derived from insn_data while xop[01] are
passed in as arguments so it seems the code wants to check the
modes are not fine already, not whether swapping is a no-op
because both are equal.

Thus I went for the obvious change at this point.

Richard.

Reply via email to