summaryrefslogtreecommitdiff
path: root/test/CodeGen/X86/shrink-compare.ll
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-04-22 18:47:44 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-04-22 18:47:44 +0000
commite7cf062537e898f830565db5dbf99ae9c928399e (patch)
tree3c87d0506e38a3039f8e6df7fc0ed061d232dd8c /test/CodeGen/X86/shrink-compare.ll
parenteac0c9dc7759b013bbe831ace1afa37bc46915c6 (diff)
downloadllvm-e7cf062537e898f830565db5dbf99ae9c928399e.tar.gz
llvm-e7cf062537e898f830565db5dbf99ae9c928399e.tar.bz2
llvm-e7cf062537e898f830565db5dbf99ae9c928399e.tar.xz
DAGCombine: fold "(zext x) == C" into "x == (trunc C)" if the trunc is lossless.
On x86 this allows to fold a load into the cmp, greatly reducing register pressure. movzbl (%rdi), %eax cmpl $47, %eax -> cmpb $47, (%rdi) This shaves 8k off gcc.o on i386. I'll leave applying the patch in README.txt to Chris :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130005 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/X86/shrink-compare.ll')
-rw-r--r--test/CodeGen/X86/shrink-compare.ll36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/CodeGen/X86/shrink-compare.ll b/test/CodeGen/X86/shrink-compare.ll
new file mode 100644
index 0000000000..7eaf9411c1
--- /dev/null
+++ b/test/CodeGen/X86/shrink-compare.ll
@@ -0,0 +1,36 @@
+; RUN: llc < %s -march=x86-64 | FileCheck %s
+
+declare void @bar()
+
+define void @test1(i32* nocapture %X) nounwind {
+entry:
+ %tmp1 = load i32* %X, align 4
+ %and = and i32 %tmp1, 255
+ %cmp = icmp eq i32 %and, 47
+ br i1 %cmp, label %if.then, label %if.end
+
+if.then:
+ tail call void @bar() nounwind
+ br label %if.end
+
+if.end:
+ ret void
+; CHECK: test1:
+; CHECK: cmpb $47, (%rdi)
+}
+
+define void @test2(i32 %X) nounwind {
+entry:
+ %and = and i32 %X, 255
+ %cmp = icmp eq i32 %and, 47
+ br i1 %cmp, label %if.then, label %if.end
+
+if.then:
+ tail call void @bar() nounwind
+ br label %if.end
+
+if.end:
+ ret void
+; CHECK: test2:
+; CHECK: cmpb $47, %dil
+}