This change is for handling of “store to invariant address” in ‘LoopAccessAnalysis’(LAA).
While analyzing loop, LAA sets ‘CanVecMem’ to false when store to invariant address appears.
928 void LoopAccessInfo::analyzeLoop(const ValueToValueMap &Strides) {
1029 if (isUniform(Ptr)) {
1030 emitAnalysis(
1031 LoopAccessReport(ST)
1032 << "write to a loop invariant address could not be vectorized");
1033 DEBUG(dbgs() << "LAA: We don't allow storing to uniform addresses\n");
1034 CanVecMem = false;
1035 return;
1036 }
This check was specific to optimizations.
We like to add a flexibility here, by letting optimizations to decide on “store to invariant address”.
Some optimizations may not be interested in “store to invariant address” and few optimization will be interested.
For the same as Adam suggested, made following change:
- Added variable ‘StoreToLoopInvariantAddress’ in ‘LoopAccessInfo’ class.
- Provided a getter function ‘hasStoreToLoopInvariantAddress’ for ‘StoreToLoopInvariantAddress’.
- Updating this variable in ‘LoopAccessInfo::analyzeLoop’ for store to invariant addresses.
- In vectorization legality ‘LoopVectorizationLegality::canVectorizeMemory’ checking this variable and returning false in case of store to invariant addresses.
Requesting to review this change.
it returns true, else returns false. ('s' at the end of return and one sentence or start new sentence with upper case)