[Bug target/30315] optimize unsigned-add overflow test on x86 to use cpu flags from addl

ubizjak at gmail dot com gcc-bugzilla@gcc.gnu.org
Sun Aug 19 18:04:00 GMT 2007



------- Comment #13 from ubizjak at gmail dot com  2007-08-19 18:03 -------
(In reply to comment #12)

>      if (sum == 0) sum = 1;
> 

> Additionally, the resulting asm seems to be a bit stupid:
> 
>         testl   %edx,   %edx
>         movl    $1,     %eax
>         cmove   %eax,   %edx
> 
> should be just
> 
>         testl   %edx,   %edx
>         sete    %dl

Not, because sete sets dl to 0 (zero) when condition is not met. The c code
above doesn't change sum when sum != 0.

Regarding the problem, described in comment #11:

Perhaps we can add CCCZmode as a common mode to otherwise orthogonal CCCmode
and CCZmode. Playing with i386_cc_modes_compatible() and ix86_match_cc_mode()
we can perhaps teach combine to CSE and merge two comparisons. To achieve this,
I think we should use (enhanced) ix86_match_cc_mode() in just added RTL
patterns.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30315



More information about the Gcc-bugs mailing list