@@ -284,6 +284,27 @@ class LLVM_ABI FullDependence final : public Dependence {
284284// / DependenceInfo - This class is the main dependence-analysis driver.
285285class DependenceInfo {
286286public:
287+ // / Represents the result of delinearization computed a depends query. Since
288+ // / a depends query analyzes the relationship between two memory accesses,
289+ // / the delinearization result has two lists of subscript expressions (one
290+ // / for each memory access), The sizes (dimensions) must be shared between
291+ // / the two accesses.
292+ // / TODO: It might be better to define this (or a variant of it) within
293+ // / Delinearize, rather than inside DependenceAnalysis.
294+ struct DelinearizedAccessesInfo {
295+ // / Subscriptions for the source memory access.
296+ SmallVector<const SCEV *, 4 > SrcSubscripts;
297+
298+ // / Subscriptions for the destination memory access.
299+ SmallVector<const SCEV *, 4 > DstSubscripts;
300+
301+ // / Sizes (dimensions) shared between the two accesses.
302+ SmallVector<const SCEV *, 4 > Sizes;
303+
304+ // / Print the delinearization result.
305+ void print (raw_ostream &OS, unsigned Depth) const ;
306+ };
307+
287308 DependenceInfo (Function *F, AAResults *AA, ScalarEvolution *SE, LoopInfo *LI)
288309 : AA(AA), SE(SE), LI(LI), F(F) {}
289310
@@ -298,9 +319,13 @@ class DependenceInfo {
298319 // / solved at compilation time. By default UnderRuntimeAssumptions is false
299320 // / for a safe approximation of the dependence relation that does not
300321 // / require runtime checks.
322+ // / If \p RecordDelinearization is provided and the delinearization process
323+ // / is successful, the result is stored in \p RecordDelinearization. It's
324+ // / primary for testing purposes.
301325 LLVM_ABI std::unique_ptr<Dependence>
302326 depends (Instruction *Src, Instruction *Dst,
303- bool UnderRuntimeAssumptions = false );
327+ bool UnderRuntimeAssumptions = false ,
328+ DelinearizedAccessesInfo *RecordDelinearization = nullptr );
304329
305330 // / getSplitIteration - Give a dependence that's splittable at some
306331 // / particular level, return the iteration that should be used to split
@@ -897,25 +922,24 @@ class DependenceInfo {
897922
898923 // / Given a linear access function, tries to recover subscripts
899924 // / for each dimension of the array element access.
900- bool tryDelinearize (Instruction *Src, Instruction *Dst,
901- SmallVectorImpl<Subscript> &Pair);
925+ std::optional<DelinearizedAccessesInfo>
926+ tryDelinearize (Instruction *Src, Instruction *Dst,
927+ SmallVectorImpl<Subscript> &Pair);
902928
903929 // / Tries to delinearize \p Src and \p Dst access functions for a fixed size
904930 // / multi-dimensional array. Calls tryDelinearizeFixedSizeImpl() to
905931 // / delinearize \p Src and \p Dst separately,
906- bool tryDelinearizeFixedSize (Instruction *Src, Instruction *Dst,
907- const SCEV *SrcAccessFn, const SCEV *DstAccessFn,
908- SmallVectorImpl<const SCEV *> &SrcSubscripts,
909- SmallVectorImpl<const SCEV *> &DstSubscripts);
932+ std::optional<DelinearizedAccessesInfo>
933+ tryDelinearizeFixedSize (Instruction *Src, Instruction *Dst,
934+ const SCEV *SrcAccessFn, const SCEV *DstAccessFn);
910935
911936 // / Tries to delinearize access function for a multi-dimensional array with
912937 // / symbolic runtime sizes.
913- // / Returns true upon success and false otherwise.
914- bool
938+ // / Returns delineazied result upon success and nullopt otherwise.
939+ std::optional<DelinearizedAccessesInfo>
915940 tryDelinearizeParametricSize (Instruction *Src, Instruction *Dst,
916- const SCEV *SrcAccessFn, const SCEV *DstAccessFn,
917- SmallVectorImpl<const SCEV *> &SrcSubscripts,
918- SmallVectorImpl<const SCEV *> &DstSubscripts);
941+ const SCEV *SrcAccessFn,
942+ const SCEV *DstAccessFn);
919943
920944 // / checkSubscript - Helper function for checkSrcSubscript and
921945 // / checkDstSubscript to avoid duplicate code
0 commit comments