From: Chris Lattner Date: Wed, 11 Apr 2007 05:02:57 +0000 (+0000) Subject: new testcases for integer abs function X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=603572a7711440d7229a6f98a4e6920fdc691848;p=oota-llvm.git new testcases for integer abs function git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35880 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/CodeGen/ARM/iabs.ll b/test/CodeGen/ARM/iabs.ll new file mode 100644 index 00000000000..26819deec64 --- /dev/null +++ b/test/CodeGen/ARM/iabs.ll @@ -0,0 +1,20 @@ +; RUN: llvm-as < %s | llc -march=arm -stats 2>&1 | grep '3 .*Number of machine instrs printed' && +; RUN: llvm-as < %s | llc -march=thumb -stats 2>&1 | grep '4 .*Number of machine instrs printed' + +;; Integer absolute value, should produce something as good as: ARM: +;; add r3, r0, r0, asr #31 +;; eor r0, r3, r0, asr #31 +;; bx lr +;; Thumb: +;; asr r2, r0, #31 +;; add r0, r0, r2 +;; eor r0, r2 +;; bx lr + +define i32 @test(i32 %a) { + %tmp1neg = sub i32 0, %a + %b = icmp sgt i32 %a, -1 + %abs = select i1 %b, i32 %a, i32 %tmp1neg + ret i32 %abs +} + diff --git a/test/CodeGen/PowerPC/iabs.ll b/test/CodeGen/PowerPC/iabs.ll new file mode 100644 index 00000000000..1414c0e67c3 --- /dev/null +++ b/test/CodeGen/PowerPC/iabs.ll @@ -0,0 +1,14 @@ +; RUN: llvm-as < %s | llc -march=ppc32 -stats 2>&1 | grep '4 .*Number of machine instrs printed' + +;; Integer absolute value, should produce something as good as: +;; srawi r2, r3, 31 +;; add r3, r3, r2 +;; xor r3, r3, r2 +;; blr +define i32 @test(i32 %a) { + %tmp1neg = sub i32 0, %a + %b = icmp sgt i32 %a, -1 + %abs = select i1 %b, i32 %a, i32 %tmp1neg + ret i32 %abs +} + diff --git a/test/CodeGen/X86/iabs.ll b/test/CodeGen/X86/iabs.ll new file mode 100644 index 00000000000..e1eab33e5eb --- /dev/null +++ b/test/CodeGen/X86/iabs.ll @@ -0,0 +1,16 @@ +; RUN: llvm-as < %s | llc -march=x86-64 -stats 2>&1 | grep '6 .*Number of machine instrs printed' + +;; Integer absolute value, should produce something at least as good as: +;; movl %edi, %eax +;; sarl $31, %eax +;; addl %eax, %edi +;; xorl %eax, %edi +;; movl %edi, %eax +;; ret +define i32 @test(i32 %a) { + %tmp1neg = sub i32 0, %a + %b = icmp sgt i32 %a, -1 + %abs = select i1 %b, i32 %a, i32 %tmp1neg + ret i32 %abs +} +