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

Chandler Carruth chandlerc at google.com
Thu Jun 7 15:18:53 PDT 2012


LGTM as well, just trying to give some tips on minimizing file check
predicates, nothing important:

--- test/CodeGen/X86/iabs.ll (revision 158160)
+++ test/CodeGen/X86/iabs.ll (working copy)
@@ -1,13 +1,18 @@
-; RUN: llc < %s -march=x86-64 -stats  |& \
-; RUN:   grep {5 .*Number of machine instrs printed}
+; RUN: llc < %s -march=x86-64 | FileCheck %s

 ;; Integer absolute value, should produce something at least as good as:
-;;       movl %edi, %ecx
-;;       sarl $31, %ecx
-;;       leal (%rdi,%rcx), %eax
-;;       xorl %ecx, %eax
+;;       movl   %edi, %eax
+;;       negl   %eax
+;;       cmovll %edi, %eax
 ;;       ret
+; rdar://10695237
 define i32 @test(i32 %a) nounwind {
+; CHECK: test:
+; CHECK: mov
+; CHECK-NEXT: neg
+; CHECK-NEXT: cmov
+; CHECK-NEXT: ret
+; CHECK-NOT: sar

You don't really need the 'sar' -NOT assertion here. Once you hit 'ret',
game's over. =] Generally, you'll need -NOT when you don't check everything
in-between the start of the interesting pattern ('mov' here), and the end
(usually 'ret').
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120607/ee23894e/attachment.html>


More information about the llvm-commits mailing list