From 603572a7711440d7229a6f98a4e6920fdc691848 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 11 Apr 2007 05:02:57 +0000 Subject: [PATCH] new testcases for integer abs function git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35880 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CodeGen/ARM/iabs.ll | 20 ++++++++++++++++++++ test/CodeGen/PowerPC/iabs.ll | 14 ++++++++++++++ test/CodeGen/X86/iabs.ll | 16 ++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 test/CodeGen/ARM/iabs.ll create mode 100644 test/CodeGen/PowerPC/iabs.ll create mode 100644 test/CodeGen/X86/iabs.ll 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 +} + -- 2.34.1