summaryrefslogtreecommitdiff
path: root/test/CodeGen/X86/isint.ll
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-10-21 03:29:32 +0000
committerDan Gohman <gohman@apple.com>2008-10-21 03:29:32 +0000
commit279c22e6da2612f024b70e5509ffb0cad32f38b2 (patch)
tree6499655e356d56dc612145ffb3a4f9f0d9694c41 /test/CodeGen/X86/isint.ll
parent3afda6e9d1a74456b9baa87ee6aabbc06e356433 (diff)
downloadllvm-279c22e6da2612f024b70e5509ffb0cad32f38b2.tar.gz
llvm-279c22e6da2612f024b70e5509ffb0cad32f38b2.tar.bz2
llvm-279c22e6da2612f024b70e5509ffb0cad32f38b2.tar.xz
Optimized FCMP_OEQ and FCMP_UNE for x86.
Where previously LLVM might emit code like this: ucomisd %xmm1, %xmm0 setne %al setp %cl orb %al, %cl jne .LBB4_2 it now emits this: ucomisd %xmm1, %xmm0 jne .LBB4_2 jp .LBB4_2 It has fewer instructions and uses fewer registers, but it does have more branches. And in the case that this code is followed by a non-fallthrough edge, it may be followed by a jmp instruction, resulting in three branch instructions in sequence. Some effort is made to avoid this situation. To achieve this, X86ISelLowering.cpp now recognizes FCMP_OEQ and FCMP_UNE in lowered form, and replace them with code that emits two branches, except in the case where it would require converting a fall-through edge to an explicit branch. Also, X86InstrInfo.cpp's branch analysis and transform code now knows now to handle blocks with multiple conditional branches. It uses loops instead of having fixed checks for up to two instructions. It can now analyze and transform code generated from FCMP_OEQ and FCMP_UNE. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57873 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/X86/isint.ll')
-rw-r--r--test/CodeGen/X86/isint.ll31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/CodeGen/X86/isint.ll b/test/CodeGen/X86/isint.ll
new file mode 100644
index 0000000000..9915bfa8d6
--- /dev/null
+++ b/test/CodeGen/X86/isint.ll
@@ -0,0 +1,31 @@
+; llvm-as < %s | llc -march=x86 > %t
+; not grep cmp %t
+; not grep xor %t
+; grep jne %t | count 1
+; grep jp %t | count 1
+; grep setnp %t | count 1
+; grep sete %t | count 1
+; grep and %t | count 1
+; grep cvt %t | count 4
+
+define i32 @isint_return(double %d) nounwind {
+ %i = fptosi double %d to i32
+ %e = sitofp i32 %i to double
+ %c = fcmp oeq double %d, %e
+ %z = zext i1 %c to i32
+ ret i32 %z
+}
+
+declare void @foo()
+
+define void @isint_branch(double %d) nounwind {
+ %i = fptosi double %d to i32
+ %e = sitofp i32 %i to double
+ %c = fcmp oeq double %d, %e
+ br i1 %c, label %true, label %false
+true:
+ call void @foo()
+ ret void
+false:
+ ret void
+}