[polly] r246441 - Always use the branch instructions to model the PHI-node writes
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 31 06:44:51 PDT 2015
I don't believe this change was necessary because we have this part:
Instruction *OpI = dyn_cast<Instruction>(Op);
if (OpI) {
BasicBlock *OpIBB = OpI->getParent();
// As we pretend there is a use (or more precise a write) of OpI in OpBB
// we have to insert a scalar dependence from the definition of OpI to
// OpBB if the definition is not in OpBB.
if (OpIBB != OpBB) {
IRAccess ScalarRead(IRAccess::READ, OpI, ZeroOffset, 1, true, OpI);
AccFuncMap[OpBB].push_back(std::make_pair(ScalarRead, PHI));
IRAccess ScalarWrite(IRAccess::MUST_WRITE, OpI, ZeroOffset, 1, true,
OpI);
AccFuncMap[OpIBB].push_back(std::make_pair(ScalarWrite, OpI));
}
}
Please tell me where I am mistaken?
On 08/31, Tobias Grosser via llvm-commits wrote:
> Author: grosser
> Date: Mon Aug 31 08:45:54 2015
> New Revision: 246441
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246441&view=rev
> Log:
> Always use the branch instructions to model the PHI-node writes
>
> Before this commit we did this only for Arguments or Constants, but indeed
> an instruction may define a value a lot higher up in the dominance tree, but
> the actual write generally needs to happen right before branching to the
> PHI node. Otherwise, the writes of different branches into PHI nodes may get
> intermixed if they lay higher up in the dominance tree.
>
> Added:
> polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-3.ll
> Modified:
> polly/trunk/lib/Analysis/TempScopInfo.cpp
>
> Modified: polly/trunk/lib/Analysis/TempScopInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/TempScopInfo.cpp?rev=246441&r1=246440&r2=246441&view=diff
> ==============================================================================
> --- polly/trunk/lib/Analysis/TempScopInfo.cpp (original)
> +++ polly/trunk/lib/Analysis/TempScopInfo.cpp Mon Aug 31 08:45:54 2015
> @@ -128,10 +128,9 @@ void TempScopInfo::buildPHIAccesses(PHIN
> }
> }
>
> - // If the operand is a constant, global or argument we use the terminator
> - // of the incoming basic block as the access instruction.
> - if (!OpI)
> - OpI = OpBB->getTerminator();
> + // Always use the terminator of the incoming basic block as the access
> + // instruction.
> + OpI = OpBB->getTerminator();
>
> IRAccess ScalarAccess(IRAccess::MUST_WRITE, PHI, ZeroOffset, 1, true, Op,
> /* IsPHI */ true);
>
> Added: polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-3.ll
> URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-3.ll?rev=246441&view=auto
> ==============================================================================
> --- polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-3.ll (added)
> +++ polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-3.ll Mon Aug 31 08:45:54 2015
> @@ -0,0 +1,49 @@
> +; RUN: opt %loadPolly -polly-codegen -polly-no-early-exit \
> +; RUN: -polly-detect-unprofitable -S < %s | FileCheck %s
> +
> +define void @foo(float* %A, i1 %cond0, i1 %cond1) {
> +entry:
> + br label %loop
> +
> +loop:
> + %indvar = phi i64 [0, %entry], [%indvar.next, %backedge]
> + %val0 = fadd float 1.0, 2.0
> + %val1 = fadd float 1.0, 2.0
> + %val2 = fadd float 1.0, 2.0
> + br i1 %cond0, label %branch1, label %backedge
> +
> +; CHECK-LABEL: polly.stmt.loop:
> +; CHECK-NEXT: %polly.subregion.iv = phi i32 [ 0, %polly.stmt.loop.entry ]
> +; CHECK-NEXT: %p_val0 = fadd float 1.000000e+00, 2.000000e+00
> +; CHECK-NEXT: %p_val1 = fadd float 1.000000e+00, 2.000000e+00
> +; CHECK-NEXT: %p_val2 = fadd float 1.000000e+00, 2.000000e+00
> +; CHECK-NEXT: store float %p_val0, float* %merge.phiops
> +; CHECK-NEXT: store float %p_val1, float* %val1.s2a
> +; CHECK-NEXT: store float %p_val2, float* %val2.s2a
> +
> +; FIXME -> The last two writes are not really needed and can be dropped if the
> +; incoming block of the PHI and the value that is used share the same
> +; non-affine region.
> +
> +branch1:
> + br i1 %cond1, label %branch2, label %backedge
> +
> +; CHECK-LABEL: polly.stmt.branch1:
> +; CHECK-NEXT: store float %p_val1, float* %merge.phiops
> +
> +branch2:
> + br label %backedge
> +
> +; CHECK-LABEL: polly.stmt.branch2:
> +; CHECK-NEXT: store float %p_val2, float* %merge.phiops
> +
> +backedge:
> + %merge = phi float [%val0, %loop], [%val1, %branch1], [%val2, %branch2]
> + %indvar.next = add i64 %indvar, 1
> + store float %merge, float* %A
> + %cmp = icmp sle i64 %indvar.next, 100
> + br i1 %cmp, label %loop, label %exit
> +
> +exit:
> + ret void
> +}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
--
Johannes Doerfert
Researcher / PhD Student
Compiler Design Lab (Prof. Hack)
Saarland University, Computer Science
Building E1.3, Room 4.31
Tel. +49 (0)681 302-57521 : doerfert at cs.uni-saarland.de
Fax. +49 (0)681 302-3065 : http://www.cdl.uni-saarland.de/people/doerfert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 213 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150831/51452013/attachment.sig>
More information about the llvm-commits
mailing list