[llvm-commits] [Patch] Optimize integer ABS on X86

Evan Cheng evan.cheng at apple.com
Wed Jun 6 18:15:29 PDT 2012


This part looks weird to me:

+  SDValue RV = performIntegerAbsCombine(N, DAG);
+  if (RV.getNode() || !Subtarget->hasBMI())
+    return RV;
+

Why is the code returning RV if its Node is null just because Subtarget->hasBMI() is false? Should the subtarget feature check happen earlier? The rest of the patch looks fine to me. Please commit after you have fixed the hasBMI issue.

Thanks,

Evan

On Jun 6, 2012, at 4:01 PM, Manman Ren <mren at apple.com> wrote:

> 
> 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
> 
> <int_abs_x86.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list