new testcases for integer abs function

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35880 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2007-04-11 05:02:57 +00:00
parent ed4e51e58e
commit 603572a771
3 changed files with 50 additions and 0 deletions

20
test/CodeGen/ARM/iabs.ll Normal file
View File

@ -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
}

View File

@ -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
}

16
test/CodeGen/X86/iabs.ll Normal file
View File

@ -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
}