[polly] r246441 - Always use the branch instructions to model the PHI-node writes
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 31 06:45:54 PDT 2015
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
+}
More information about the llvm-commits
mailing list