summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-11-23 13:54:17 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-11-23 13:54:17 +0000
commitf238f50aaf8a68f16dcc43a017aa32cbb73e938e (patch)
treef2f2a0dd61a14d7ee11ff864268fbc0fc96406c0 /test
parente4513b1fc5eb44885a3a21e83664289e30542cdf (diff)
downloadllvm-f238f50aaf8a68f16dcc43a017aa32cbb73e938e.tar.gz
llvm-f238f50aaf8a68f16dcc43a017aa32cbb73e938e.tar.bz2
llvm-f238f50aaf8a68f16dcc43a017aa32cbb73e938e.tar.xz
X86: Use btq for bit tests if the immediate can't be encoded in 32 bits.
Before: movabsq $4294967296, %rax ## encoding: [0x48,0xb8,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00] testq %rax, %rdi ## encoding: [0x48,0x85,0xf8] jne LBB0_2 ## encoding: [0x75,A] After: btq $32, %rdi ## encoding: [0x48,0x0f,0xba,0xe7,0x20] jb LBB0_2 ## encoding: [0x72,A] btq is usually slower than testq because it doesn't fuse with the jump, but here we're better off saving one register and a giant movabsq. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145103 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/CodeGen/X86/btq.ll35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/CodeGen/X86/btq.ll b/test/CodeGen/X86/btq.ll
new file mode 100644
index 0000000000..9c137a7239
--- /dev/null
+++ b/test/CodeGen/X86/btq.ll
@@ -0,0 +1,35 @@
+; RUN: llc < %s -march=x86-64 | FileCheck %s
+
+declare void @bar()
+
+define void @test1(i64 %foo) nounwind {
+ %and = and i64 %foo, 4294967296
+ %tobool = icmp eq i64 %and, 0
+ br i1 %tobool, label %if.end, label %if.then
+
+; CHECK: test1:
+; CHECK: btq $32
+
+if.then:
+ tail call void @bar() nounwind
+ br label %if.end
+
+if.end:
+ ret void
+}
+
+define void @test2(i64 %foo) nounwind {
+ %and = and i64 %foo, 2147483648
+ %tobool = icmp eq i64 %and, 0
+ br i1 %tobool, label %if.end, label %if.then
+
+; CHECK: test2:
+; CHECK: testl $-2147483648
+
+if.then:
+ tail call void @bar() nounwind
+ br label %if.end
+
+if.end:
+ ret void
+}