[PATCH] D68082: [SCEV] Don't add Predicates with OptForSize

Ayal Zaks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 4 08:05:28 PDT 2019


Ayal added a subscriber: sanjoy.
Ayal added a comment.

Changing `PredicatedScalarEvolution::getAsAddRec()` to consider hasOptSize sounds a bit strange to me; after all the transformation that created PSCEV should have considered this; adding @sanjoy for more thoughts on such a proposed SCEV change.

The earlier "fix at the core" thought was for LV to do something along these lines:

  @@ -409,7 +409,9 @@ int LoopVectorizationLegality::isConsecutivePtr(Value *Ptr) {
     const ValueToValueMap &Strides =
         getSymbolicStrides() ? *getSymbolicStrides() : ValueToValueMap();
   
  -  int Stride = getPtrStride(PSE, Ptr, TheLoop, Strides, true, false);
  +  bool CanAddPredicates = !TheLoop->getHeader()->getParent()->hasOptSize();
  +  int Stride =
  +      getPtrStride(PSE, Ptr, TheLoop, Strides, CanAddPredicates, false);
     if (Stride == 1 || Stride == -1)
       return Stride;
     return 0;

and the related "BTW, a related opportunity is // FIXME: Avoid specializing for stride==1 instead of bailing out" was for LAI to do something along these lines:

  @@ -2295,6 +2295,11 @@ void LoopAccessInfo::collectStridedAccess(Value *MemAccess) {
                          "versioning:");
     LLVM_DEBUG(dbgs() << "  Ptr: " << *Ptr << " Stride: " << *Stride << "\n");
   
  +  if (TheLoop->getHeader()->getParent()->hasOptSize()) {
  +    /* issue an LLVM_DEBUG message that versioning is avoided due to opt-for-size */
  +    return;
  +  }
  +
     // Avoid adding the "Stride == 1" predicate when we know that
     // Stride >= Trip-Count. Such a predicate will effectively optimize a single
     // or zero iteration loop, as Trip-Count <= Stride == 1.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68082/new/

https://reviews.llvm.org/D68082





More information about the llvm-commits mailing list