summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen
diff options
context:
space:
mode:
authorDehao Chen <dehao@google.com>2016-09-12 20:23:28 +0000
committerDehao Chen <dehao@google.com>2016-09-12 20:23:28 +0000
commit9bbb941acfba70d557c572d102412dba91fbd128 (patch)
treec42ff036e39bd292d81496696ebdf00fa2343fb1 /llvm/test/CodeGen
parentd0c1c3220a1c16a9f8d903c190bc0bdfdc008954 (diff)
downloadbcm5719-llvm-9bbb941acfba70d557c572d102412dba91fbd128.tar.gz
bcm5719-llvm-9bbb941acfba70d557c572d102412dba91fbd128.zip
Lower consecutive select instructions correctly.
Summary: If consecutive select instructions are lowered separately in CGP, it will introduce redundant condition check and branches that cannot be removed by later optimization phases. This patch lowers all consecutive select instructions at the same to to avoid inefficent code as demonstrated in https://llvm.org/bugs/show_bug.cgi?id=29095 Reviewers: davidxl Subscribers: vsk, llvm-commits Differential Revision: https://reviews.llvm.org/D24147 llvm-svn: 281252
Diffstat (limited to 'llvm/test/CodeGen')
-rw-r--r--llvm/test/CodeGen/X86/pseudo_cmov_lower2.ll44
1 files changed, 44 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/pseudo_cmov_lower2.ll b/llvm/test/CodeGen/X86/pseudo_cmov_lower2.ll
index 0133963b36d..38712a96b2b 100644
--- a/llvm/test/CodeGen/X86/pseudo_cmov_lower2.ll
+++ b/llvm/test/CodeGen/X86/pseudo_cmov_lower2.ll
@@ -98,3 +98,47 @@ entry:
%d5 = fdiv double %d4, %d3
ret double %d5
}
+
+; This test checks that only a single jae gets generated in the final code
+; for lowering the CMOV pseudos that get created for this IR. The tricky part
+; of this test is that it tests the special code in CodeGenPrepare.
+;
+; CHECK-LABEL: foo5:
+; CHECK: jae
+; CHECK-NOT: jae
+define double @foo5(float %p1, double %p2, double %p3) nounwind {
+entry:
+ %c1 = fcmp oge float %p1, 0.000000e+00
+ %d0 = fadd double %p2, 1.25e0
+ %d1 = fadd double %p3, 1.25e0
+ %d2 = select i1 %c1, double %d0, double %d1, !prof !0
+ %d3 = select i1 %c1, double %d2, double %p2, !prof !0
+ %d4 = select i1 %c1, double %d3, double %p3, !prof !0
+ %d5 = fsub double %d2, %d3
+ %d6 = fadd double %d5, %d4
+ ret double %d6
+}
+
+; We should expand select instructions into 3 conditional branches as their
+; condtions are different.
+;
+; CHECK-LABEL: foo6:
+; CHECK: jae
+; CHECK: jae
+; CHECK: jae
+define double @foo6(float %p1, double %p2, double %p3) nounwind {
+entry:
+ %c1 = fcmp oge float %p1, 0.000000e+00
+ %c2 = fcmp oge float %p1, 1.000000e+00
+ %c3 = fcmp oge float %p1, 2.000000e+00
+ %d0 = fadd double %p2, 1.25e0
+ %d1 = fadd double %p3, 1.25e0
+ %d2 = select i1 %c1, double %d0, double %d1, !prof !0
+ %d3 = select i1 %c2, double %d2, double %p2, !prof !0
+ %d4 = select i1 %c3, double %d3, double %p3, !prof !0
+ %d5 = fsub double %d2, %d3
+ %d6 = fadd double %d5, %d4
+ ret double %d6
+}
+
+!0 = !{!"branch_weights", i32 1, i32 2000}
OpenPOWER on IntegriCloud