summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/SimplifyCFG
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2015-04-24 20:57:56 +0000
committerHans Wennborg <hans@hanshq.net>2015-04-24 20:57:56 +0000
commit86ac630585e8bd92739d6ef5edca664387efc27e (patch)
tree2043fa8c207aa410d6d7bece3241a0e78eaa7956 /llvm/test/Transforms/SimplifyCFG
parent4472b776b0c3a564385322ba5dcb7e2673d59a89 (diff)
downloadbcm5719-llvm-86ac630585e8bd92739d6ef5edca664387efc27e.tar.gz
bcm5719-llvm-86ac630585e8bd92739d6ef5edca664387efc27e.zip
SimplifyCFG: Correctly handle switch lookup tables which fully cover the input type and use bit tests to check for holes
When using bit tests for hole checks, we call AddPredecessorToBlock to give the phi node a value from the bit test block. This would break if we've previously called removePredecessor on the default destination because the switch is fully covered. Test case by Mark Lacey. llvm-svn: 235771
Diffstat (limited to 'llvm/test/Transforms/SimplifyCFG')
-rw-r--r--llvm/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll29
1 files changed, 29 insertions, 0 deletions
diff --git a/llvm/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll b/llvm/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
index cdc0488991a..732e7cafe5e 100644
--- a/llvm/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
+++ b/llvm/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
@@ -1273,3 +1273,32 @@ end:
; CHECK-LABEL: @pr20210
; CHECK: switch i8 %x
}
+
+; Make sure we do not crash due to trying to generate an unguarded
+; lookup (since i3 can only hold values in the range of explicit
+; values) and simultaneously trying to generate a branch to deal with
+; the fact that we have holes in the range.
+define i32 @covered_switch_with_bit_tests(i3) {
+entry:
+ switch i3 %0, label %l6 [
+ i3 -3, label %l5
+ i3 -4, label %l5
+ i3 3, label %l1
+ i3 2, label %l1
+ ]
+
+l1: br label %l2
+
+l2:
+ %x = phi i32 [ 1, %l1 ], [ 2, %l5 ]
+ br label %l6
+
+l5: br label %l2
+
+l6:
+ %r = phi i32 [ %x, %l2 ], [ 0, %entry ]
+ ret i32 %r
+; CHECK-LABEL: @covered_switch_with_bit_tests
+; CHECK: entry
+; CHECK-NEXT: switch
+}
OpenPOWER on IntegriCloud