Skip to content

Commit 22a7f6d

Browse files
authored
Revert "[LV] Autovectorization for the all-in-one histogram intrinsic" (#98493)
Reverts #91458 to deal with post-commit reviewer requests.
1 parent 621bcfc commit 22a7f6d

File tree

12 files changed

+38
-759
lines changed

12 files changed

+38
-759
lines changed

llvm/include/llvm/Analysis/LoopAccessAnalysis.h

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ class MemoryDepChecker {
144144
// on MinDepDistBytes.
145145
BackwardVectorizable,
146146
// Same, but may prevent store-to-load forwarding.
147-
BackwardVectorizableButPreventsForwarding,
148-
// Access is to a loop loaded value, but is part of a histogram operation.
149-
Histogram
147+
BackwardVectorizableButPreventsForwarding
150148
};
151149

152150
/// String version of the types.
@@ -203,8 +201,7 @@ class MemoryDepChecker {
203201
/// Only checks sets with elements in \p CheckDeps.
204202
bool areDepsSafe(DepCandidates &AccessSets, MemAccessInfoList &CheckDeps,
205203
const DenseMap<Value *, SmallVector<const Value *, 16>>
206-
&UnderlyingObjects,
207-
const SmallPtrSetImpl<const Value *> &HistogramPtrs);
204+
&UnderlyingObjects);
208205

209206
/// No memory dependence was encountered that would inhibit
210207
/// vectorization.
@@ -355,8 +352,7 @@ class MemoryDepChecker {
355352
isDependent(const MemAccessInfo &A, unsigned AIdx, const MemAccessInfo &B,
356353
unsigned BIdx,
357354
const DenseMap<Value *, SmallVector<const Value *, 16>>
358-
&UnderlyingObjects,
359-
const SmallPtrSetImpl<const Value *> &HistogramPtrs);
355+
&UnderlyingObjects);
360356

361357
/// Check whether the data dependence could prevent store-load
362358
/// forwarding.
@@ -397,8 +393,7 @@ class MemoryDepChecker {
397393
const MemAccessInfo &A, Instruction *AInst, const MemAccessInfo &B,
398394
Instruction *BInst,
399395
const DenseMap<Value *, SmallVector<const Value *, 16>>
400-
&UnderlyingObjects,
401-
const SmallPtrSetImpl<const Value *> &HistogramPtrs);
396+
&UnderlyingObjects);
402397
};
403398

404399
class RuntimePointerChecking;
@@ -450,15 +445,6 @@ struct PointerDiffInfo {
450445
NeedsFreeze(NeedsFreeze) {}
451446
};
452447

453-
struct HistogramInfo {
454-
LoadInst *Load;
455-
Instruction *Update;
456-
StoreInst *Store;
457-
458-
HistogramInfo(LoadInst *Load, Instruction *Update, StoreInst *Store)
459-
: Load(Load), Update(Update), Store(Store) {}
460-
};
461-
462448
/// Holds information about the memory runtime legality checks to verify
463449
/// that a group of pointers do not overlap.
464450
class RuntimePointerChecking {
@@ -639,13 +625,6 @@ class RuntimePointerChecking {
639625
/// Checks for both memory dependences and the SCEV predicates contained in the
640626
/// PSE must be emitted in order for the results of this analysis to be valid.
641627
class LoopAccessInfo {
642-
/// Represents whether the memory access dependencies in the loop:
643-
/// * Prohibit vectorization
644-
/// * Allow for vectorization (possibly with runtime checks)
645-
/// * Allow for vectorization (possibly with runtime checks),
646-
/// as long as histogram operations are supported.
647-
enum VecMemPossible { CantVec = 0, NormalVec = 1, HistogramVec = 2 };
648-
649628
public:
650629
LoopAccessInfo(Loop *L, ScalarEvolution *SE, const TargetTransformInfo *TTI,
651630
const TargetLibraryInfo *TLI, AAResults *AA, DominatorTree *DT,
@@ -657,11 +636,7 @@ class LoopAccessInfo {
657636
/// hasStoreStoreDependenceInvolvingLoopInvariantAddress and
658637
/// hasLoadStoreDependenceInvolvingLoopInvariantAddress also need to be
659638
/// checked.
660-
bool canVectorizeMemory() const { return CanVecMem == NormalVec; }
661-
662-
bool canVectorizeMemoryWithHistogram() const {
663-
return CanVecMem == NormalVec || CanVecMem == HistogramVec;
664-
}
639+
bool canVectorizeMemory() const { return CanVecMem; }
665640

666641
/// Return true if there is a convergent operation in the loop. There may
667642
/// still be reported runtime pointer checks that would be required, but it is
@@ -689,10 +664,6 @@ class LoopAccessInfo {
689664
unsigned getNumStores() const { return NumStores; }
690665
unsigned getNumLoads() const { return NumLoads;}
691666

692-
const SmallVectorImpl<HistogramInfo> &getHistograms() const {
693-
return Histograms;
694-
}
695-
696667
/// The diagnostics report generated for the analysis. E.g. why we
697668
/// couldn't analyze the loop.
698669
const OptimizationRemarkAnalysis *getReport() const { return Report.get(); }
@@ -744,8 +715,8 @@ class LoopAccessInfo {
744715
private:
745716
/// Analyze the loop. Returns true if all memory access in the loop can be
746717
/// vectorized.
747-
VecMemPossible analyzeLoop(AAResults *AA, LoopInfo *LI,
748-
const TargetLibraryInfo *TLI, DominatorTree *DT);
718+
bool analyzeLoop(AAResults *AA, LoopInfo *LI, const TargetLibraryInfo *TLI,
719+
DominatorTree *DT);
749720

750721
/// Check if the structure of the loop allows it to be analyzed by this
751722
/// pass.
@@ -786,7 +757,7 @@ class LoopAccessInfo {
786757
unsigned NumStores = 0;
787758

788759
/// Cache the result of analyzeLoop.
789-
VecMemPossible CanVecMem = CantVec;
760+
bool CanVecMem = false;
790761
bool HasConvergentOp = false;
791762

792763
/// Indicator that there are two non vectorizable stores to the same uniform
@@ -806,13 +777,6 @@ class LoopAccessInfo {
806777
/// If an access has a symbolic strides, this maps the pointer value to
807778
/// the stride symbol.
808779
DenseMap<Value *, const SCEV *> SymbolicStrides;
809-
810-
/// Holds the load, update, and store instructions for all histogram-style
811-
/// operations found in the loop.
812-
SmallVector<HistogramInfo, 2> Histograms;
813-
814-
/// Storing Histogram Pointers
815-
SmallPtrSet<const Value *, 2> HistogramPtrs;
816780
};
817781

818782
/// Return the SCEV corresponding to a pointer with the symbolic stride

llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -390,23 +390,6 @@ class LoopVectorizationLegality {
390390
unsigned getNumStores() const { return LAI->getNumStores(); }
391391
unsigned getNumLoads() const { return LAI->getNumLoads(); }
392392

393-
std::optional<const HistogramInfo *> getHistogramInfo(Instruction *I) const {
394-
for (const HistogramInfo &HGram : LAI->getHistograms())
395-
if (HGram.Load == I || HGram.Update == I || HGram.Store == I)
396-
return &HGram;
397-
398-
return std::nullopt;
399-
}
400-
401-
std::optional<const HistogramInfo *>
402-
getHistogramForStore(StoreInst *SI) const {
403-
for (const HistogramInfo &HGram : LAI->getHistograms())
404-
if (HGram.Store == SI)
405-
return &HGram;
406-
407-
return std::nullopt;
408-
}
409-
410393
PredicatedScalarEvolution *getPredicatedScalarEvolution() const {
411394
return &PSE;
412395
}

0 commit comments

Comments
 (0)