[PATCH] D48026: [ScopHelper] Provide support for recognising collective invariant loads
SAHIL GIRISH YERAWAR via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 11 07:35:18 PDT 2018
cs15btech11044 created this revision.
cs15btech11044 added reviewers: bollu, philip.pfaffe, Meinersbur.
Herald added a subscriber: llvm-commits.
This patch aims to provide support for detecting load patterns which are collectively invariant but right now `isHoistableLoad()`is checking each load instruction individually which cannot detect the load pattern as a whole.
Repository:
rPLO Polly
https://reviews.llvm.org/D48026
Files:
include/polly/Support/ScopHelper.h
lib/Analysis/ScopDetection.cpp
lib/Support/ScopHelper.cpp
Index: lib/Support/ScopHelper.cpp
===================================================================
--- lib/Support/ScopHelper.cpp
+++ lib/Support/ScopHelper.cpp
@@ -442,9 +442,22 @@
}
bool polly::isHoistableLoad(LoadInst *LInst, Region &R, LoopInfo &LI,
- ScalarEvolution &SE, const DominatorTree &DT) {
+ ScalarEvolution &SE, const DominatorTree &DT,
+ InvariantLoadsSetTy &RequiredILS) {
Loop *L = LI.getLoopFor(LInst->getParent());
auto *Ptr = LInst->getPointerOperand();
+
+ auto *ptr_operand = dyn_cast<Instruction>(Ptr);
+ if (ptr_operand && isa<GetElementPtrInst>(ptr_operand)) {
+ auto *prev_inst = dyn_cast<Instruction>(ptr_operand->getOperand(0));
+ if (prev_inst && isa<LoadInst>(prev_inst)) {
+ auto *lt = dyn_cast<LoadInst>(prev_inst);
+ for (int i = 0; i < RequiredILS.size(); i++)
+ if (RequiredILS[i] == lt)
+ return true;
+ }
+ }
+
const SCEV *PtrSCEV = SE.getSCEVAtScope(Ptr, L);
while (L && R.contains(L)) {
if (!SE.isLoopInvariant(PtrSCEV, L))
Index: lib/Analysis/ScopDetection.cpp
===================================================================
--- lib/Analysis/ScopDetection.cpp
+++ lib/Analysis/ScopDetection.cpp
@@ -484,7 +484,7 @@
if (Context.RequiredILS.count(Load))
continue;
- if (!isHoistableLoad(Load, CurRegion, LI, SE, DT))
+ if (!isHoistableLoad(Load, CurRegion, LI, SE, DT, RequiredILS))
return false;
for (auto NonAffineRegion : Context.NonAffineSubRegionSet) {
@@ -938,7 +938,7 @@
auto *V = dyn_cast<Value>(Unknown->getValue());
if (auto *Load = dyn_cast<LoadInst>(V)) {
if (Context.CurRegion.contains(Load) &&
- isHoistableLoad(Load, CurRegion, LI, SE, DT))
+ isHoistableLoad(Load, CurRegion, LI, SE, DT, Context.RequiredILS))
Context.RequiredILS.insert(Load);
continue;
}
@@ -1152,7 +1152,8 @@
Instruction *Inst = dyn_cast<Instruction>(Ptr.getValue());
if (Inst && Context.CurRegion.contains(Inst)) {
auto *Load = dyn_cast<LoadInst>(Inst);
- if (Load && isHoistableLoad(Load, Context.CurRegion, LI, SE, DT)) {
+ if (Load && isHoistableLoad(Load, Context.CurRegion, LI, SE, DT,
+ Context.RequiredILS)) {
Context.RequiredILS.insert(Load);
continue;
}
Index: include/polly/Support/ScopHelper.h
===================================================================
--- include/polly/Support/ScopHelper.h
+++ include/polly/Support/ScopHelper.h
@@ -394,7 +394,8 @@
///
/// @return True if @p LInst can be hoisted in @p R.
bool isHoistableLoad(llvm::LoadInst *LInst, llvm::Region &R, llvm::LoopInfo &LI,
- llvm::ScalarEvolution &SE, const llvm::DominatorTree &DT);
+ llvm::ScalarEvolution &SE, const llvm::DominatorTree &DT,
+ InvariantLoadsSetTy &RequiredILS);
/// Return true iff @p V is an intrinsic that we ignore during code
/// generation.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48026.150750.patch
Type: text/x-patch
Size: 3123 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180611/e61dd4bd/attachment.bin>
More information about the llvm-commits
mailing list