summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/SimplifyCFG
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2013-04-16 08:35:36 +0000
committerHans Wennborg <hans@hanshq.net>2013-04-16 08:35:36 +0000
commitc9e1d992796ba1dd20004495038fbf18deeadb65 (patch)
tree20f7e7768048cd93556bb0e5449909c20e450057 /llvm/test/Transforms/SimplifyCFG
parent8edce4ee6276df36969283bf98b8bef898fb548c (diff)
downloadbcm5719-llvm-c9e1d992796ba1dd20004495038fbf18deeadb65.tar.gz
bcm5719-llvm-c9e1d992796ba1dd20004495038fbf18deeadb65.zip
simplifycfg: Fix integer overflow converting switch into icmp.
If a switch instruction has a case for every possible value of its type, with the same successor, SimplifyCFG would replace it with an icmp ult, but the computation of the bound overflows in that case, which inverts the test. Patch by Jed Davis! llvm-svn: 179587
Diffstat (limited to 'llvm/test/Transforms/SimplifyCFG')
-rw-r--r--llvm/test/Transforms/SimplifyCFG/switch-to-icmp.ll18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/test/Transforms/SimplifyCFG/switch-to-icmp.ll b/llvm/test/Transforms/SimplifyCFG/switch-to-icmp.ll
index 414f8475bc2..e9a6db45cb0 100644
--- a/llvm/test/Transforms/SimplifyCFG/switch-to-icmp.ll
+++ b/llvm/test/Transforms/SimplifyCFG/switch-to-icmp.ll
@@ -37,3 +37,21 @@ lor.end:
; CHECK: @test2
; CHECK: %switch = icmp ult i32 %x, 2
}
+
+define i32 @test3(i1 %flag) {
+entry:
+ switch i1 %flag, label %bad [
+ i1 true, label %good
+ i1 false, label %good
+ ]
+
+good:
+ ret i32 0
+
+bad:
+ ret i32 1
+
+; CHECK: @test3
+; CHECK: entry:
+; CHECK-NEXT: ret i32 0
+}
OpenPOWER on IntegriCloud