http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49095
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |jakub at gcc dot gnu.org
|gnu.org |
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-27
10:35:52 UTC ---
Created attachment 24366
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24366
gcc47-pr49095.patch
Untested patch which solves this (for some cases) using peephole2.
The reason combiner can't do this is that there are no LOG_LINKS in between the
comparison and memory store, those two insns are independent and thus don't
ever show up together in the same try_combine call (together with their
dependencies). And we generate:
movq (%rsi), %rax
subq $1, %rax
testq %rax, %rax
movq %rax, (%rsi)
je .L4
instead of
movq (%rsi), %rax
subq $1, %rax
movq %rax, (%rsi)
je .L4
because in case of multiple uses, LOG_LINKS are on the first use, and the
memory store is before the test during combine (only later scheduling changes
it).
Thus the test has no LOG_LINKS at all and isn't being attempted to be merged
together with the subtraction.