diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2014-01-27 13:11:43 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2014-01-27 13:11:43 +0000 |
commit | 08aa38d39b870d7b2b5774740fb9e9d3a218b47a (patch) | |
tree | 8fa072e7fa2ea6af21c8fdc0f6f0bd0bd510c419 /test | |
parent | 3202becf5ea308afcfe09f7f65fbb7bf58db46b5 (diff) | |
download | llvm-08aa38d39b870d7b2b5774740fb9e9d3a218b47a.tar.gz llvm-08aa38d39b870d7b2b5774740fb9e9d3a218b47a.tar.bz2 llvm-08aa38d39b870d7b2b5774740fb9e9d3a218b47a.tar.xz |
ConstantHoisting: We can't insert instructions directly in front of a PHI node.
Insert before the terminating instruction of the dominating block instead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200218 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/Transforms/ConstantHoisting/X86/lit.local.cfg | 4 | ||||
-rw-r--r-- | test/Transforms/ConstantHoisting/X86/phi.ll | 48 |
2 files changed, 52 insertions, 0 deletions
diff --git a/test/Transforms/ConstantHoisting/X86/lit.local.cfg b/test/Transforms/ConstantHoisting/X86/lit.local.cfg new file mode 100644 index 0000000000..ba763cf03f --- /dev/null +++ b/test/Transforms/ConstantHoisting/X86/lit.local.cfg @@ -0,0 +1,4 @@ +targets = set(config.root.targets_to_build.split()) +if not 'X86' in targets: + config.unsupported = True + diff --git a/test/Transforms/ConstantHoisting/X86/phi.ll b/test/Transforms/ConstantHoisting/X86/phi.ll new file mode 100644 index 0000000000..abbba81654 --- /dev/null +++ b/test/Transforms/ConstantHoisting/X86/phi.ll @@ -0,0 +1,48 @@ +; RUN: opt -S -consthoist < %s | FileCheck %s + +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.9.0" + +; PR18626 +define i8* @test1(i1 %cmp, i64* %tmp) { +entry: + call void @foo(i8* inttoptr (i64 68719476735 to i8*)) + br i1 %cmp, label %if.end, label %return + +if.end: ; preds = %bb1 + call void @foo(i8* inttoptr (i64 68719476736 to i8*)) + br label %return + +return: + %retval.0 = phi i8* [ null, %entry ], [ inttoptr (i64 68719476736 to i8*), %if.end ] + store i64 1172321806, i64* %tmp + ret i8* %retval.0 + +; CHECK-LABEL: @test1 +; CHECK: entry: +; CHECK: %const_mat = add i64 %const, 1 +; CHECK-NEXT: %1 = inttoptr i64 %const_mat to i8* +; CHECK-NEXT: br i1 %cmp +; CHECK: %retval.0 = phi i8* [ null, %entry ], [ %1, %if.end ] +} + +define void @test2(i1 %cmp, i64** %tmp) { +entry: + call void @foo(i8* inttoptr (i64 68719476736 to i8*)) + br i1 %cmp, label %if.end, label %return + +if.end: ; preds = %bb1 + call void @foo(i8* inttoptr (i64 68719476736 to i8*)) + br label %return + +return: + store i64* inttoptr (i64 68719476735 to i64*), i64** %tmp + ret void + +; CHECK-LABEL: @test2 +; CHECK: return: +; CHECK-NEXT: %const_mat = add i64 %const, -1 +; CHECK-NEXT: inttoptr i64 %const_mat to i64* +} + +declare void @foo(i8*) |