summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Grosser <tobias@grosser.es>2016-08-18 10:45:57 +0000
committerTobias Grosser <tobias@grosser.es>2016-08-18 10:45:57 +0000
commit1c18440958e3b4f37b870f61069a5bc80f56b1e4 (patch)
tree534d3688a2510dbb33a8fcb6b9ee1a38fdb8d1bf
parente86f80c45e565b737ad6322c79658b8535a7bf0e (diff)
downloadbcm5719-llvm-1c18440958e3b4f37b870f61069a5bc80f56b1e4.tar.gz
bcm5719-llvm-1c18440958e3b4f37b870f61069a5bc80f56b1e4.zip
[BlockGenerator] Invalidate SCEV values for instructions in scop
We already invalidated a couple of critical values earlier on, but we now invalidate all instructions contained in a scop after the scop has been code generated. This is necessary as later scops may otherwise obtain SCEV expressions that reference values in the earlier scop that before dominated the later scop, but which had been moved into the conditional branch and consequently do not dominate the later scop any more. If these very values are then used during code generation of the later scop, we generate used that are dominated by the values they use. This fixes: http://llvm.org/PR28984 llvm-svn: 279047
-rw-r--r--polly/include/polly/CodeGen/BlockGenerators.h12
-rw-r--r--polly/lib/CodeGen/BlockGenerators.cpp14
-rw-r--r--polly/test/Isl/CodeGen/hoisted_load_escapes_through_phi.ll4
3 files changed, 29 insertions, 1 deletions
diff --git a/polly/include/polly/CodeGen/BlockGenerators.h b/polly/include/polly/CodeGen/BlockGenerators.h
index 20c4d9b8889..0a71f5dd784 100644
--- a/polly/include/polly/CodeGen/BlockGenerators.h
+++ b/polly/include/polly/CodeGen/BlockGenerators.h
@@ -546,6 +546,18 @@ protected:
/// @param BB The basic block code for which code has been generated.
/// @param BBMap A local map from old to new instructions.
void removeDeadInstructions(BasicBlock *BB, ValueMapT &BBMap);
+
+ /// @brief Invalidate the scalar evolution expressions for a scop.
+ ///
+ /// This function invalidates the scalar evolution results for all
+ /// instructions that are part of a given scop. This is necessary to ensure
+ /// that later scops do not obtain scalar evolution expressions that reference
+ /// values that earlier dominated the later scop, but have been moved in the
+ /// conditional part of an earlier scop and consequently do not any more
+ /// dominate the later scop.
+ ///
+ /// @param S The scop to invalidate.
+ void invalidateScalarEvolution(Scop &S);
};
/// @brief Generate a new vector basic block for a polyhedral statement.
diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp
index 982d7e7546f..aeca08f54b0 100644
--- a/polly/lib/CodeGen/BlockGenerators.cpp
+++ b/polly/lib/CodeGen/BlockGenerators.cpp
@@ -646,11 +646,25 @@ void BlockGenerator::createExitPHINodeMerges(Scop &S) {
}
}
+void BlockGenerator::invalidateScalarEvolution(Scop &S) {
+ for (auto &Stmt : S)
+ if (Stmt.isBlockStmt())
+ for (auto &Inst : *Stmt.getBasicBlock())
+ SE.forgetValue(&Inst);
+ else if (Stmt.isRegionStmt())
+ for (auto *BB : Stmt.getRegion()->blocks())
+ for (auto &Inst : *BB)
+ SE.forgetValue(&Inst);
+ else
+ llvm_unreachable("Unexpected statement type found");
+}
+
void BlockGenerator::finalizeSCoP(Scop &S) {
findOutsideUsers(S);
createScalarInitialization(S);
createExitPHINodeMerges(S);
createScalarFinalization(S);
+ invalidateScalarEvolution(S);
}
VectorBlockGenerator::VectorBlockGenerator(BlockGenerator &BlockGen,
diff --git a/polly/test/Isl/CodeGen/hoisted_load_escapes_through_phi.ll b/polly/test/Isl/CodeGen/hoisted_load_escapes_through_phi.ll
index 038919f985e..e8fa68893f9 100644
--- a/polly/test/Isl/CodeGen/hoisted_load_escapes_through_phi.ll
+++ b/polly/test/Isl/CodeGen/hoisted_load_escapes_through_phi.ll
@@ -1,5 +1,7 @@
; RUN: opt %loadPolly -S -polly-codegen \
-; RUN: -polly-invariant-load-hoisting < %s | FileCheck %s
+; RUN: -polly-invariant-load-hoisting=false < %s | FileCheck %s
+; RUN: opt %loadPolly -S -polly-codegen \
+; RUN: -polly-invariant-load-hoisting=true < %s | FileCheck %s
;
; Check that we generate valid code even if the load of cont_STACKPOINTER is
; hoisted in one SCoP and used (through the phi node %tmp2).
OpenPOWER on IntegriCloud