From f681437cb082bf6fb5da43c8acd4e1313ba3b213 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Tue, 12 Nov 2013 12:24:36 +0000 Subject: 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 --- test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'test/Transforms/SimplifyCFG') 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( -- cgit v1.2.3