diff --git a/polly/lib/Analysis/TempScopInfo.cpp b/polly/lib/Analysis/TempScopInfo.cpp index c7479e5c68be..8065e73f5870 100644 --- a/polly/lib/Analysis/TempScopInfo.cpp +++ b/polly/lib/Analysis/TempScopInfo.cpp @@ -317,13 +317,14 @@ void TempScopInfo::buildAccessFunctions(Region &R, BasicBlock &BB, if (PHINode *PHI = dyn_cast(Inst)) buildPHIAccesses(PHI, R, Functions, NonAffineSubRegion); - if (!isa(Inst) && - buildScalarDependences(Inst, &R, NonAffineSubRegion)) { + if (buildScalarDependences(Inst, &R, NonAffineSubRegion)) { // If the Instruction is used outside the statement, we need to build the // write access. - IRAccess ScalarAccess(IRAccess::MUST_WRITE, Inst, ZeroOffset, 1, true, - Inst); - Functions.push_back(std::make_pair(ScalarAccess, Inst)); + if (!isa(Inst)) { + IRAccess ScalarAccess(IRAccess::MUST_WRITE, Inst, ZeroOffset, 1, true, + Inst); + Functions.push_back(std::make_pair(ScalarAccess, Inst)); + } } } diff --git a/polly/test/ScopInfo/read-only-scalars.ll b/polly/test/ScopInfo/read-only-scalars.ll index 18dad36f36ce..a2176f80b367 100644 --- a/polly/test/ScopInfo/read-only-scalars.ll +++ b/polly/test/ScopInfo/read-only-scalars.ll @@ -10,8 +10,11 @@ ; SCALARS: ReadAccess := [Reduction Type: NONE] [Scalar: 1] ; SCALARS: { Stmt_stmt1[i0] -> MemRef_scalar[] }; +; SCALARS: ReadAccess := [Reduction Type: NONE] [Scalar: 1] +; SCALARS: { Stmt_stmt1[i0] -> MemRef_scalar2[] }; -define void @foo(float* noalias %A, float %scalar) { + +define void @foo(float* noalias %A, float* %B, float %scalar, float %scalar2) { entry: br label %loop @@ -23,6 +26,7 @@ stmt1: %val = load float, float* %A %sum = fadd float %val, %scalar store float %sum, float* %A + store float %scalar2, float* %B br label %loop.backedge loop.backedge: