[llvm] r322056 - [CGP] Fix Complex addressing mode for offset
Hans Wennborg via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 17 05:03:18 PST 2018
Merged to 6.0 in r322645.
On Tue, Jan 9, 2018 at 5:37 AM, Serguei Katkov via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: skatkov
> Date: Mon Jan 8 20:37:06 2018
> New Revision: 322056
>
> URL: http://llvm.org/viewvc/llvm-project?rev=322056&view=rev
> Log:
> [CGP] Fix Complex addressing mode for offset
>
> If the offset is differ in two addressing mode we can continue only if
> ScaleReg is not set due to we will use it as merge of different offsets.
>
> It should fix PR35799 and PR35805.
>
> Reviewers: john.brawn, reames
> Reviewed By: reames
> Subscribers: llvm-commits
> Differential Revision: https://reviews.llvm.org/D41227
>
>
> Added:
> llvm/trunk/test/Transforms/CodeGenPrepare/X86/sink-addrmode-select.ll
> Modified:
> llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
>
> Modified: llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp?rev=322056&r1=322055&r2=322056&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp (original)
> +++ llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp Mon Jan 8 20:37:06 2018
> @@ -2700,8 +2700,13 @@ public:
> // we still need to collect it due to original value is different.
> // And later we will need all original values as anchors during
> // finding the common Phi node.
> + // We also must reject the case when base offset is different and
> + // scale reg is not null, we cannot handle this case due to merge of
> + // different offsets will be used as ScaleReg.
> if (DifferentField != ExtAddrMode::MultipleFields &&
> - DifferentField != ExtAddrMode::ScaleField) {
> + DifferentField != ExtAddrMode::ScaleField &&
> + (DifferentField != ExtAddrMode::BaseOffsField ||
> + !NewAddrMode.ScaledReg)) {
> AddrModes.emplace_back(NewAddrMode);
> return true;
> }
>
> Added: llvm/trunk/test/Transforms/CodeGenPrepare/X86/sink-addrmode-select.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/CodeGenPrepare/X86/sink-addrmode-select.ll?rev=322056&view=auto
> ==============================================================================
> --- llvm/trunk/test/Transforms/CodeGenPrepare/X86/sink-addrmode-select.ll (added)
> +++ llvm/trunk/test/Transforms/CodeGenPrepare/X86/sink-addrmode-select.ll Mon Jan 8 20:37:06 2018
> @@ -0,0 +1,19 @@
> +; RUN: opt -S -codegenprepare -disable-complex-addr-modes=false -addr-sink-new-select=true %s | FileCheck %s --check-prefix=CHECK
> +target datalayout =
> +"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
> +target triple = "x86_64-unknown-linux-gnu"
> +
> +; Select when both offset and scale reg are present.
> +define i64 @test1(i1 %c, i64* %b, i64 %scale) {
> +; CHECK-LABEL: @test1
> +entry:
> +; CHECK-LABEL: entry:
> + %g = getelementptr inbounds i64, i64* %b, i64 %scale
> + %g1 = getelementptr inbounds i64, i64* %g, i64 8
> + %g2 = getelementptr inbounds i64, i64* %g, i64 16
> + %s = select i1 %c, i64* %g1, i64* %g2
> +; CHECK-NOT: sunkaddr
> + %v = load i64 , i64* %s, align 8
> + ret i64 %v
> +}
> +
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list