[llvm-commits] [Patch] Optimize integer ABS on X86
Manman Ren
mren at apple.com
Wed Jun 6 16:01:48 PDT 2012
Optimize generated code for integer ABS on X86:
movl %edi, %ecx
sarl $31, %ecx
leal (%rdi,%rcx), %eax
xorl %ecx, %eax
ret
TO
movl %edi, %eax
negl %eax
cmovll %edi, %eax
ret
This reduces code size and has better performance on sandy bridge.
There exists a target-independent DAG combine for integer ABS, which converts abs to sar+add+xor.
For X86, I tried to match this pattern back to neg+cmov. This is implemented in PerformXorCombine.
Thanks,
Manman
-------------- next part --------------
A non-text attachment was scrubbed...
Name: int_abs_x86.patch
Type: application/octet-stream
Size: 3356 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120606/c53c8c11/attachment.obj>
More information about the llvm-commits
mailing list