forked from OSchip/llvm-project
Always model PHI nodes in scop (if not in same nonaffine subregion)
Before we only modeled PHI nodes if at least one incoming basic block was itself part of the region, now we always model them except if all of their operands are part of a single non-affine subregion which we model as a black-box. This change only affects PHI nodes in the entry block, that have exactly one incoming edge. Before this change, we did not model them and as a result code generation would not know how to code generate them. With this change, code generation can code generate them like any other PHI node. This issue was exposed by r244606. Before this change simplifyRegion would have moved these PHI nodes out of the SCoP, so we would never have tried to code generate them. We could implement this behavior again, but changing the IR after the scop has been modeled and transformed always adds a risk of us invalidating earlier analysis results. It seems more save and overall also more consistent to just model and handle this one-entry-edge PHI nodes like any other PHI node in the scop. Solution proposed by: Michael Kruse <llvm@meinersbur.de> llvm-svn: 244721
This commit is contained in:
parent
fba24b3775
commit
a77cea49d1
|
@ -114,18 +114,20 @@ void TempScopInfo::buildPHIAccesses(PHINode *PHI, Region &R,
|
|||
// PHI nodes are modeled as if they had been demoted prior to the SCoP
|
||||
// detection. Hence, the PHI is a load of a new memory location in which the
|
||||
// incoming value was written at the end of the incoming basic block.
|
||||
bool Written = false;
|
||||
bool OnlyNonAffineSubRegionOperands = true;
|
||||
for (unsigned u = 0; u < PHI->getNumIncomingValues(); u++) {
|
||||
Value *Op = PHI->getIncomingValue(u);
|
||||
BasicBlock *OpBB = PHI->getIncomingBlock(u);
|
||||
|
||||
if (!R.contains(OpBB))
|
||||
continue;
|
||||
|
||||
// Do not build scalar dependences inside a non-affine subregion.
|
||||
if (NonAffineSubRegion && NonAffineSubRegion->contains(OpBB))
|
||||
continue;
|
||||
|
||||
OnlyNonAffineSubRegionOperands = false;
|
||||
|
||||
if (!R.contains(OpBB))
|
||||
continue;
|
||||
|
||||
Instruction *OpI = dyn_cast<Instruction>(Op);
|
||||
if (OpI) {
|
||||
BasicBlock *OpIBB = OpI->getParent();
|
||||
|
@ -145,14 +147,12 @@ void TempScopInfo::buildPHIAccesses(PHINode *PHI, Region &R,
|
|||
if (!OpI)
|
||||
OpI = OpBB->getTerminator();
|
||||
|
||||
Written = true;
|
||||
|
||||
IRAccess ScalarAccess(IRAccess::MUST_WRITE, PHI, ZeroOffset, 1, true,
|
||||
/* IsPHI */ true);
|
||||
AccFuncMap[OpBB].push_back(std::make_pair(ScalarAccess, OpI));
|
||||
}
|
||||
|
||||
if (Written) {
|
||||
if (!OnlyNonAffineSubRegionOperands) {
|
||||
IRAccess ScalarAccess(IRAccess::READ, PHI, ZeroOffset, 1, true,
|
||||
/* IsPHI */ true);
|
||||
Functions.push_back(std::make_pair(ScalarAccess, PHI));
|
||||
|
|
|
@ -4,14 +4,18 @@
|
|||
; PHI node. LCSSA may create such PHI nodes. This is a breakdown of this case in
|
||||
; the function 'Laguerre_With_Deflation' of oggenc from LLVM's test-suite.
|
||||
;
|
||||
; XFAIL: *
|
||||
;
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
|
||||
define void @test(i64 %n, float* noalias nonnull %A, float %a) {
|
||||
entry:
|
||||
br label %entry.split
|
||||
|
||||
; CHECK-LABEL: %polly.split_new_and_old
|
||||
; CHECK-NEXT: store float %a, float* %b.phiops
|
||||
|
||||
; CHECK-LABEL: polly.stmt.entry.split
|
||||
; CHECK-NEXT: %b.phiops.reload = load float, float* %b.phiops
|
||||
|
||||
entry.split:
|
||||
%b = phi float [ %a, %entry ]
|
||||
store float %b, float* %A, align 4
|
||||
|
|
Loading…
Reference in New Issue