[Bug target/83133] Superflous x86 test instructions in generated assembly.

ubizjak at gmail dot com gcc-bugzilla@gcc.gnu.org
Fri Nov 24 17:55:00 GMT 2017


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

--- Comment #17 from Uroš Bizjak <ubizjak at gmail dot com> ---
(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. This
optimization can be implemented by changing condition of *sub<mode>_2 pattern
from:

ix86_match_ccmode (insn, CCGOCmode)

to

ix86_match_ccmode (insn, flag_wrapv ? CCGOCmode : CCNOmode)


More information about the Gcc-bugs mailing list