This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/30315] optimize unsigned-add overflow test on x86 to use cpu flags from addl
- From: "ubizjak at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Aug 2007 18:03:59 -0000
- Subject: [Bug target/30315] optimize unsigned-add overflow test on x86 to use cpu flags from addl
- References: <bug-30315-11337@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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