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

--- Comment #19 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Uroš Bizjak from comment #17)
> (In reply to Marc Glisse from comment #15)
> > Gcc's RTL internal representation sees the same thing for your code and for
> > 
> >   int diff = (unsigned)a - (unsigned)b;
> > 
> > llvm represents both differently and generates different code for the two.
> 
> GCC represents unsigned comparison with LTU and signed with LT.

Above I only used unsigned for the subtraction, not for the comparison. This
was a way to explain to Maxim that in RTL, we have lost the information that an
overflow would be undefined behavior. Expansion is currently the last chance we
get to use the GIMPLE information about overflow. Otherwise, we would need to
find a way in RTL to represent this overflow behavior (say that it sets OF to
false, but we are already using a parallel to say it sets CCGOC so I don't know
how we would spell that).

By the way, writing a<b or a>b instead of diff<0 or diff>0 doesn't help, it
actually hurts gcc. I thought we had a pass to merge adjacent subtraction and
comparison of the same numbers...

Reply via email to