summaryrefslogtreecommitdiff
path: root/test/Transforms/SimplifyCFG
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-11-12 12:24:36 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-11-12 12:24:36 +0000
commitf681437cb082bf6fb5da43c8acd4e1313ba3b213 (patch)
treee5df711dbf88734aac9721c82e307584bddc0e99 /test/Transforms/SimplifyCFG
parent92e94a2ee44aefda151125fdb62bf9d5b54edfb2 (diff)
downloadllvm-f681437cb082bf6fb5da43c8acd4e1313ba3b213.tar.gz
llvm-f681437cb082bf6fb5da43c8acd4e1313ba3b213.tar.bz2
llvm-f681437cb082bf6fb5da43c8acd4e1313ba3b213.tar.xz
SimplifyCFG: Use existing constant folding logic when forming switch tables.
Both simpler and more powerful than the hand-rolled folding logic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194475 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/SimplifyCFG')
-rw-r--r--test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll9
1 files changed, 6 insertions, 3 deletions
diff --git a/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll b/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
index 71259c99b0..368732711a 100644
--- a/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
+++ b/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
@@ -711,7 +711,7 @@ return:
ret i32 %retval.0
}
-define i32 @cprop(i32 %x) {
+define i32 @cprop(i32 %x, i32 %y) {
entry:
switch i32 %x, label %sw.default [
i32 1, label %return
@@ -727,7 +727,8 @@ sw.bb1: br label %return
sw.bb2:
%and = and i32 %x, 1
- %tobool = icmp ne i32 %and, 0
+ %and.ptr = inttoptr i32 %and to i8*
+ %tobool = icmp ne i8* %and.ptr, null
%cond = select i1 %tobool, i32 -123, i32 456
%sub = sub nsw i32 %x, %cond
br label %return
@@ -735,13 +736,15 @@ sw.bb2:
sw.bb3:
%trunc = trunc i32 %x to i8
%sext = sext i8 %trunc to i32
+ %select.i = icmp sgt i32 %sext, 0
+ %select = select i1 %select.i, i32 %sext, i32 %y
br label %return
sw.default:
br label %return
return:
- %retval.0 = phi i32 [ 123, %sw.default ], [ %sext, %sw.bb3 ], [ %sub, %sw.bb2 ], [ 42, %sw.bb1 ], [ 5, %entry ]
+ %retval.0 = phi i32 [ 123, %sw.default ], [ %select, %sw.bb3 ], [ %sub, %sw.bb2 ], [ 42, %sw.bb1 ], [ 5, %entry ]
ret i32 %retval.0
; CHECK-LABEL: @cprop(