summaryrefslogtreecommitdiffstats
path: root/polly/lib/Analysis/ScopDetection.cpp
diff options
context:
space:
mode:
authorMichael Kruse <llvm@meinersbur.de>2017-03-07 20:28:43 +0000
committerMichael Kruse <llvm@meinersbur.de>2017-03-07 20:28:43 +0000
commit5a4ec5c42b84a56b8c7177f04bd65183f5286402 (patch)
tree551e24e15ecfc184d8cea862853eeb4f7a974933 /polly/lib/Analysis/ScopDetection.cpp
parent06b1af5bf1172be1b3f6fa762f0c901656678e6d (diff)
downloadbcm5719-llvm-5a4ec5c42b84a56b8c7177f04bd65183f5286402.tar.gz
bcm5719-llvm-5a4ec5c42b84a56b8c7177f04bd65183f5286402.zip
[ScopDetection] Require LoadInst base pointers to be hoisted.
Only when load-hoisted we can be sure the base pointer is invariant during the SCoP's execution. Most of the time it would be added to the required hoists for the alias checks anyway, except with -polly-ignore-aliasing, -polly-use-runtime-alias-checks=0 or if AliasAnalysis is already sure it doesn't alias with anything (for instance if there is no other pointer to alias with). Two more parts in Polly assume that this load-hoisting took place: - setNewAccessRelation() which contains an assert which tests this. - BlockGenerator which would use to the base ptr from the original code if not load-hoisted (if the access expression is regenerated) Differential Revision: https://reviews.llvm.org/D30694 llvm-svn: 297195
Diffstat (limited to 'polly/lib/Analysis/ScopDetection.cpp')
-rw-r--r--polly/lib/Analysis/ScopDetection.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index 690655201a1..1d2b3669159 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -638,18 +638,27 @@ bool ScopDetection::isValidIntrinsicInst(IntrinsicInst &II,
return false;
}
-bool ScopDetection::isInvariant(const Value &Val, const Region &Reg) const {
+bool ScopDetection::isInvariant(Value &Val, const Region &Reg,
+ DetectionContext &Ctx) const {
// A reference to function argument or constant value is invariant.
if (isa<Argument>(Val) || isa<Constant>(Val))
return true;
- const Instruction *I = dyn_cast<Instruction>(&Val);
+ Instruction *I = dyn_cast<Instruction>(&Val);
if (!I)
return false;
if (!Reg.contains(I))
return true;
+ // Loads within the SCoP may read arbitrary values, need to hoist them. If it
+ // is not hoistable, it will be rejected later, but here we assume it is and
+ // that makes the value invariant.
+ if (auto LI = dyn_cast<LoadInst>(I)) {
+ Ctx.RequiredILS.insert(LI);
+ return true;
+ }
+
if (I->mayHaveSideEffects())
return false;
@@ -663,7 +672,7 @@ bool ScopDetection::isInvariant(const Value &Val, const Region &Reg) const {
return false;
for (const Use &Operand : I->operands())
- if (!isInvariant(*Operand, Reg))
+ if (!isInvariant(*Operand, Reg, Ctx))
return false;
return true;
@@ -911,7 +920,7 @@ bool ScopDetection::isValidAccess(Instruction *Inst, const SCEV *AF,
// Check that the base address of the access is invariant in the current
// region.
- if (!isInvariant(*BV, Context.CurRegion))
+ if (!isInvariant(*BV, Context.CurRegion, Context))
return invalid<ReportVariantBasePtr>(Context, /*Assert=*/true, BV, Inst);
AF = SE->getMinusSCEV(AF, BP);
OpenPOWER on IntegriCloud