diff options
| author | Serguei Katkov <serguei.katkov@azul.com> | 2017-11-29 05:51:26 +0000 |
|---|---|---|
| committer | Serguei Katkov <serguei.katkov@azul.com> | 2017-11-29 05:51:26 +0000 |
| commit | 5036459ae30920a4c5d34baa9d246f8a61ccbfe6 (patch) | |
| tree | 9002c0a90f9faf1b915c1beeb3a68d326c0bf621 /llvm/test/Transforms/CodeGenPrepare | |
| parent | 0010707e1c0181dccbea5e8f352a4e5fc126ed12 (diff) | |
| download | bcm5719-llvm-5036459ae30920a4c5d34baa9d246f8a61ccbfe6.tar.gz bcm5719-llvm-5036459ae30920a4c5d34baa9d246f8a61ccbfe6.zip | |
[CGP] Fix common type handling in optimizeMemoryInst
If common type is different we should bail out due to we will not be
able to create a select or Phi of these values.
Basically it is done in ExtAddrMode::compare however it does not work
if we handle the null first and then two values of different types.
so add a check in initializeMap as well. The check in ExtAddrMode::compare
is used as earlier bail out.
Reviewers: reames, john.brawn
Reviewed By: john.brawn
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D40479
llvm-svn: 319292
Diffstat (limited to 'llvm/test/Transforms/CodeGenPrepare')
| -rw-r--r-- | llvm/test/Transforms/CodeGenPrepare/X86/sink-addrmode-base.ll | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/llvm/test/Transforms/CodeGenPrepare/X86/sink-addrmode-base.ll b/llvm/test/Transforms/CodeGenPrepare/X86/sink-addrmode-base.ll index f56f99c551d..5cb64f23aba 100644 --- a/llvm/test/Transforms/CodeGenPrepare/X86/sink-addrmode-base.ll +++ b/llvm/test/Transforms/CodeGenPrepare/X86/sink-addrmode-base.ll @@ -508,3 +508,36 @@ fallthrough: %v = add i32 %v1, %v2 ret i32 %v } + +; Different types but null is the first? +define i32 @test19(i1 %cond1, i1 %cond2, i64* %b2, i8* %b1) { +; CHECK-LABEL: @test19 +entry: + %g1 = getelementptr inbounds i64, i64* %b2, i64 5 + %bc1 = bitcast i64* %g1 to i32* + br i1 %cond1, label %if.then1, label %if.then2 + +if.then1: + %g2 = getelementptr inbounds i8, i8* %b1, i64 40 + %bc2 = bitcast i8* %g2 to i32* + br label %fallthrough + +if.then2: + %bc1_1 = bitcast i64* %g1 to i32* + br i1 %cond2, label %fallthrough, label %if.then3 + +if.then3: + %g3 = getelementptr inbounds i64, i64* null, i64 5 + %bc1_2 = bitcast i64* %g3 to i32* + br label %fallthrough + +fallthrough: +; CHECK-NOT: sunk_phi + %c = phi i32* [%bc2, %if.then1], [%bc1_1, %if.then2], [%bc1_2, %if.then3] + %v1 = load i32, i32* %c, align 4 + %g1_1 = getelementptr inbounds i64, i64* %b2, i64 5 + %bc1_1_1 = bitcast i64* %g1_1 to i32* + %v2 = load i32, i32* %bc1_1_1, align 4 + %v = add i32 %v1, %v2 + ret i32 %v +} |

