[PATCH] D14496: X86: More efficient codegen for 64-bit compare-and-branch
Hans Wennborg via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 9 07:00:05 PST 2015
hans added a comment.
Thanks for the quick reply!
In http://reviews.llvm.org/D14496#285017, @mkuper wrote:
> test(long long, long long):
> movl 4(%esp), %eax
> subl 12(%esp), %eax
> movl 8(%esp), %edx
> sbbl 16(%esp), %edx
> jge ..B1.3
> movl $1, %eax
> ret
> ..B1.3:
> movl $2, %eax
> ret
>
>
> Do you think it may be worth lowering the new pseudo to that, instead of the proposed sequence?
Ooh, that looks very nice indeed. Thinking about cmp as a subtraction, this wide subtraction seems like a natural way to do it. I wonder why MSVC doesn't do it this way..
By the way, is there a reason ICC is using %edx instead of %eax for the second move and sbb? It seems to me that the register pressure here should be the same as for my proposed sequence, i.e. only one register needed.
Maybe we could also use this for the equality comparisons?
I'm mainly coming at this from a binary size perspective. Your suggestion is 4 bytes shorter than my test_slt. It's also 2 bytes shorter than my test_eq, so I like it :-)
http://reviews.llvm.org/D14496
More information about the llvm-commits
mailing list