https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102239

--- Comment #10 from Segher Boessenkool <segher at gcc dot gnu.org> ---
(In reply to luoxhu from comment #9)
> > It does matter, if what you are want to see is if it is smaller than zero or
> > greater than zero.  CCmode includes those things.  There is a CCEQmode for
> > if only the EQ bit is set correctly.
> 
> Got it, thanks. As the example in c#7.  If CCmode is LT, rotate data to
> highest bits will get negative result and set CR0 to negative, which is
> unexpected. 

CCmode is all three (or four, for non-fast FP) comparison results at once.
You can use for example both LT and EQ on the same result.  In CCEQmode
only the EQ bit is valid.

> > Some pattern that just does this as an rldicr, as a single insn.  It will
> > have to be excluded by the 2insn thing (it is only a single insn itself!),
> > and it will have to have comparison mode CCEQ only.
> 
> I was motivated by the clang code, and tried to rotate the data to LSB
> instead, it doesn't suffer from CCmode issue again?  Will this be simpler
> than the combine & new pattern solution?

It is incorrect, in a similar way.

It also is sub-optimal, it is better to tell GCC that this pattern will be
only one machine insn, so that it can consider that when choosing the best
insn patterns to use.

Also note the comment right before this code:

  /* If it is one stretch of ones, it is DImode; shift left, mask, then
     shift right.  This generates better code than doing the masks without
     shifts, or shifting first right and then left.  */

Reply via email to