Skip to content

Commit b8f4874

Browse files
kasuga-fjGeneraluseAI
authored andcommitted
[Delinearization] Remove tryDelinearizeFixedSizeImpl (llvm#169046)
`tryDelinearizeFixedSizeImpl` is a heuristic function relying on GEP's type information. Using these information to drive an optimization heuristic is not allowed, so this function should be removed. As llvm#161822 and llvm#164798 have eliminated all calls to this, this patch removes the function itself.
1 parent ac4827e commit b8f4874

File tree

3 files changed

+4
-54
lines changed

3 files changed

+4
-54
lines changed

llvm/include/llvm/Analysis/Delinearization.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,8 @@ bool findFixedSizeArrayDimensions(ScalarEvolution &SE, const SCEV *Expr,
133133
/// terms exist in the \p Expr. In other words, it assumes that the all step
134134
/// values are constant.
135135
///
136-
/// This function is intended to replace getIndexExpressionsFromGEP and
137-
/// tryDelinearizeFixedSizeImpl. They rely on the GEP source element type so
138-
/// that they will be removed in the future.
136+
/// This function is intended to replace getIndexExpressionsFromGEP. They rely
137+
/// on the GEP source element type so that will be removed in the future.
139138
bool delinearizeFixedSizeArray(ScalarEvolution &SE, const SCEV *Expr,
140139
SmallVectorImpl<const SCEV *> &Subscripts,
141140
SmallVectorImpl<const SCEV *> &Sizes,
@@ -155,17 +154,6 @@ bool getIndexExpressionsFromGEP(ScalarEvolution &SE,
155154
SmallVectorImpl<const SCEV *> &Subscripts,
156155
SmallVectorImpl<int> &Sizes);
157156

158-
/// Implementation of fixed size array delinearization. Try to delinearize
159-
/// access function for a fixed size multi-dimensional array, by deriving
160-
/// subscripts from GEP instructions. Returns true upon success and false
161-
/// otherwise. \p Inst is the load/store instruction whose pointer operand is
162-
/// the one we want to delinearize. \p AccessFn is its corresponding SCEV
163-
/// expression w.r.t. the surrounding loop.
164-
bool tryDelinearizeFixedSizeImpl(ScalarEvolution *SE, Instruction *Inst,
165-
const SCEV *AccessFn,
166-
SmallVectorImpl<const SCEV *> &Subscripts,
167-
SmallVectorImpl<int> &Sizes);
168-
169157
struct DelinearizationPrinterPass
170158
: public PassInfoMixin<DelinearizationPrinterPass> {
171159
explicit DelinearizationPrinterPass(raw_ostream &OS);

llvm/include/llvm/Analysis/DependenceAnalysis.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,8 +773,8 @@ class DependenceInfo {
773773
SmallVectorImpl<Subscript> &Pair);
774774

775775
/// Tries to delinearize \p Src and \p Dst access functions for a fixed size
776-
/// multi-dimensional array. Calls tryDelinearizeFixedSizeImpl() to
777-
/// delinearize \p Src and \p Dst separately,
776+
/// multi-dimensional array. Calls delinearizeFixedSizeArray() to delinearize
777+
/// \p Src and \p Dst separately,
778778
bool tryDelinearizeFixedSize(Instruction *Src, Instruction *Dst,
779779
const SCEV *SrcAccessFn, const SCEV *DstAccessFn,
780780
SmallVectorImpl<const SCEV *> &SrcSubscripts,

llvm/lib/Analysis/Delinearization.cpp

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -704,44 +704,6 @@ bool llvm::getIndexExpressionsFromGEP(ScalarEvolution &SE,
704704
return !Subscripts.empty();
705705
}
706706

707-
bool llvm::tryDelinearizeFixedSizeImpl(
708-
ScalarEvolution *SE, Instruction *Inst, const SCEV *AccessFn,
709-
SmallVectorImpl<const SCEV *> &Subscripts, SmallVectorImpl<int> &Sizes) {
710-
Value *SrcPtr = getLoadStorePointerOperand(Inst);
711-
712-
// Check the simple case where the array dimensions are fixed size.
713-
auto *SrcGEP = dyn_cast<GetElementPtrInst>(SrcPtr);
714-
if (!SrcGEP)
715-
return false;
716-
717-
getIndexExpressionsFromGEP(*SE, SrcGEP, Subscripts, Sizes);
718-
719-
// Check that the two size arrays are non-empty and equal in length and
720-
// value.
721-
// TODO: it would be better to let the caller to clear Subscripts, similar
722-
// to how we handle Sizes.
723-
if (Sizes.empty() || Subscripts.size() <= 1) {
724-
Subscripts.clear();
725-
return false;
726-
}
727-
728-
// Check that for identical base pointers we do not miss index offsets
729-
// that have been added before this GEP is applied.
730-
Value *SrcBasePtr = SrcGEP->getOperand(0)->stripPointerCasts();
731-
const SCEVUnknown *SrcBase =
732-
dyn_cast<SCEVUnknown>(SE->getPointerBase(AccessFn));
733-
if (!SrcBase || SrcBasePtr != SrcBase->getValue()) {
734-
Subscripts.clear();
735-
return false;
736-
}
737-
738-
assert(Subscripts.size() == Sizes.size() + 1 &&
739-
"Expected equal number of entries in the list of size and "
740-
"subscript.");
741-
742-
return true;
743-
}
744-
745707
namespace {
746708

747709
void printDelinearization(raw_ostream &O, Function *F, LoopInfo *LI,

0 commit comments

Comments
 (0)