summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-04-25 16:56:52 +0000
committerSanjay Patel <spatel@rotateright.com>2016-04-25 16:56:52 +0000
commit43c7af68898b730650c6df957741471f9de0c72a (patch)
treee23f023d220f451bc5d85202e3e657fbff3a9c4d
parentfa508e8b6db39c6d47cb27e8b6f7a81f2f08d473 (diff)
downloadbcm5719-llvm-43c7af68898b730650c6df957741471f9de0c72a.tar.gz
bcm5719-llvm-43c7af68898b730650c6df957741471f9de0c72a.zip
add tests for potential CGP transform (PR27344)
llvm-svn: 267426
-rw-r--r--llvm/test/CodeGen/X86/cmov-into-branch.ll32
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/cmov-into-branch.ll b/llvm/test/CodeGen/X86/cmov-into-branch.ll
index 8830357d54d..99aa4d51429 100644
--- a/llvm/test/CodeGen/X86/cmov-into-branch.ll
+++ b/llvm/test/CodeGen/X86/cmov-into-branch.ll
@@ -64,3 +64,35 @@ define i32 @test5(i32 %a, i32* nocapture %b, i32 %x, i32 %y) {
%cond5 = select i1 %cmp, i32 %cond, i32 %x
ret i32 %cond5
}
+
+; If a select is not obviously predictable, don't turn it into a branch.
+define i32 @weighted_select1(i32 %a, i32 %b) {
+; CHECK-LABEL: weighted_select1:
+; CHECK: # BB#0:
+; CHECK-NEXT: testl %edi, %edi
+; CHECK-NEXT: cmovnel %edi, %esi
+; CHECK-NEXT: movl %esi, %eax
+; CHECK-NEXT: retq
+;
+ %cmp = icmp ne i32 %a, 0
+ %sel = select i1 %cmp, i32 %a, i32 %b, !prof !0
+ ret i32 %sel
+}
+
+; TODO: If a select is obviously predictable, turn it into a branch.
+define i32 @weighted_select2(i32 %a, i32 %b) {
+; CHECK-LABEL: weighted_select2:
+; CHECK: # BB#0:
+; CHECK-NEXT: testl %edi, %edi
+; CHECK-NEXT: cmovnel %edi, %esi
+; CHECK-NEXT: movl %esi, %eax
+; CHECK-NEXT: retq
+;
+ %cmp = icmp ne i32 %a, 0
+ %sel = select i1 %cmp, i32 %a, i32 %b, !prof !1
+ ret i32 %sel
+}
+
+!0 = !{!"branch_weights", i32 1, i32 99}
+!1 = !{!"branch_weights", i32 1, i32 100}
+
OpenPOWER on IntegriCloud