summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/X86/cmov-into-branch.ll
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-05-09 17:31:55 +0000
committerSanjay Patel <spatel@rotateright.com>2016-05-09 17:31:55 +0000
commitc7b91e65d8960da9e9fb6a3d044f7da71d5879fa (patch)
treef683b451658c8243ab494eb9ae7b646ba9da9ecd /llvm/test/CodeGen/X86/cmov-into-branch.ll
parentb5935bfd7dda5ce37f57f3f1902eb6855d948738 (diff)
downloadbcm5719-llvm-c7b91e65d8960da9e9fb6a3d044f7da71d5879fa.tar.gz
bcm5719-llvm-c7b91e65d8960da9e9fb6a3d044f7da71d5879fa.zip
[CGP] avoid crashing from weightlessness
It's possible that we have branch weights with 0 values. In that case, don't try to create an impossible BranchProbability. llvm-svn: 268935
Diffstat (limited to 'llvm/test/CodeGen/X86/cmov-into-branch.ll')
-rw-r--r--llvm/test/CodeGen/X86/cmov-into-branch.ll14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/cmov-into-branch.ll b/llvm/test/CodeGen/X86/cmov-into-branch.ll
index 35c1d3498a5..acb5a2bb51f 100644
--- a/llvm/test/CodeGen/X86/cmov-into-branch.ll
+++ b/llvm/test/CodeGen/X86/cmov-into-branch.ll
@@ -114,8 +114,22 @@ define i32 @weighted_select3(i32 %a, i32 %b) {
ret i32 %sel
}
+; Weightlessness is no reason to die.
+define i32 @unweighted_select(i32 %a, i32 %b) {
+; CHECK-LABEL: unweighted_select:
+; 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 !3
+ ret i32 %sel
+}
!0 = !{!"branch_weights", i32 1, i32 99}
!1 = !{!"branch_weights", i32 1, i32 100}
!2 = !{!"branch_weights", i32 100, i32 1}
+!3 = !{!"branch_weights", i32 0, i32 0}
OpenPOWER on IntegriCloud