summaryrefslogtreecommitdiff
path: root/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
commita121e24c541097b51309a06297005ac257b6728f (patch)
treec66c93df0e4b1c98ebbfdc64c151eee5bdc45efa /test/Transforms/SimplifyCFG
parentad36608499429cc9dc67b95fed8732a294e6f02e (diff)
downloadllvm-a121e24c541097b51309a06297005ac257b6728f.tar.gz
llvm-a121e24c541097b51309a06297005ac257b6728f.tar.bz2
llvm-a121e24c541097b51309a06297005ac257b6728f.tar.xz
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! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179587 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/SimplifyCFG')
-rw-r--r--test/Transforms/SimplifyCFG/switch-to-icmp.ll18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/Transforms/SimplifyCFG/switch-to-icmp.ll b/test/Transforms/SimplifyCFG/switch-to-icmp.ll
index 414f8475bc..e9a6db45cb 100644
--- a/test/Transforms/SimplifyCFG/switch-to-icmp.ll
+++ b/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
+}