summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2015-01-09 22:13:31 +0000
committerHans Wennborg <hans@hanshq.net>2015-01-09 22:13:31 +0000
commitdcc6e5bc0365f484a78408e1841d1c81e32cd96c (patch)
tree5a70c7c76b19f7ea79f80b66af43530b1a1f67d9 /llvm/test
parentec1f2c2cab6d00f7193c335ac06b984bb0c480e6 (diff)
downloadbcm5719-llvm-dcc6e5bc0365f484a78408e1841d1c81e32cd96c.tar.gz
bcm5719-llvm-dcc6e5bc0365f484a78408e1841d1c81e32cd96c.zip
SimplifyCFG: check uses of constant-foldable instrs in switch destinations (PR20210)
The previous code assumed that such instructions could not have any uses outside CaseDest, with the motivation that the instruction could not dominate CommonDest because CommonDest has phi nodes in it. That simply isn't true; e.g., CommonDest could have an edge back to itself. llvm-svn: 225552
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll40
1 files changed, 40 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 95c9cc539d2..22f18cd4d43 100644
--- a/llvm/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
+++ b/llvm/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
@@ -1204,3 +1204,43 @@ return:
; CHECK-NEXT: [[R:%.+]] = select i1 %cmp
; CHECK-NEXT: ret i32 [[R]]
}
+
+define void @pr20210(i8 %x, i1 %y) {
+; %z has uses outside of its BB or the phi it feeds into,
+; so doing a table lookup and jumping directly to while.cond would
+; cause %z to cease dominating all its uses.
+
+entry:
+ br i1 %y, label %sw, label %intermediate
+
+sw:
+ switch i8 %x, label %end [
+ i8 7, label %intermediate
+ i8 3, label %intermediate
+ i8 2, label %intermediate
+ i8 1, label %intermediate
+ i8 0, label %intermediate
+ ]
+
+intermediate:
+ %z = zext i8 %x to i32
+ br label %while.cond
+
+while.cond:
+ %i = phi i32 [ %z, %intermediate ], [ %j, %while.body ]
+ %b = icmp ne i32 %i, 7
+ br i1 %b, label %while.body, label %while.end
+
+while.body:
+ %j = add i32 %i, 1
+ br label %while.cond
+
+while.end:
+ call void @exit(i32 %z)
+ unreachable
+
+end:
+ ret void
+; CHECK-LABEL: @pr20210
+; CHECK: switch i8 %x
+}
OpenPOWER on IntegriCloud