[PATCH] D83329: [PGO][PGSO] Add profile guided size optimization to loop vectorization legality.

Hiroshi Yamauchi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 20 21:16:35 PDT 2020


yamauchi added a comment.

PTAL. This is the diff of the patches before/after the latest fix.

  70c70,76
  < +        BFI(BFI), PSI(PSI) {}
  ---
  > +        BFI(BFI), PSI(PSI) {
  > +    // Query this against the original loop and save it here because the profile
  > +    // of the original loop header may change as the transformation happens.
  > +    OptForSizeBasedOnProfile = llvm::shouldOptimizeForSize(
  > +        OrigLoop->getHeader(), PSI, BFI, PGSOQueryType::IRPass);
  > +  }
  > +
  74c80
  < @@ -779,6 +781,10 @@ protected:
  ---
  > @@ -779,6 +787,14 @@ protected:
  81a88,91
  > +
  > +  // Whether this loop should be optimized for size based on profile guided size
  > +  // optimizatios.
  > +  bool OptForSizeBasedOnProfile;
  85c95
  < @@ -789,9 +795,10 @@ public:
  ---
  > @@ -789,9 +805,10 @@ public:
  98c108
  < @@ -2754,7 +2761,9 @@ void InnerLoopVectorizer::emitSCEVChecks(Loop *L, BasicBlock *Bypass) {
  ---
  > @@ -2754,7 +2771,8 @@ void InnerLoopVectorizer::emitSCEVChecks(Loop *L, BasicBlock *Bypass) {
  104,105c114
  < +           llvm::shouldOptimizeForSize(L->getHeader(), PSI, BFI,
  < +                                       PGSOQueryType::IRPass)) &&
  ---
  > +           OptForSizeBasedOnProfile) &&
  109c118
  < @@ -2800,7 +2809,9 @@ void InnerLoopVectorizer::emitMemRuntimeChecks(Loop *L, BasicBlock *Bypass) {
  ---
  > @@ -2800,7 +2818,7 @@ void InnerLoopVectorizer::emitMemRuntimeChecks(Loop *L, BasicBlock *Bypass) {
  114,116c123
  < +  if (MemCheckBlock->getParent()->hasOptSize() ||
  < +      llvm::shouldOptimizeForSize(L->getHeader(), PSI, BFI,
  < +                                  PGSOQueryType::IRPass)) {
  ---
  > +  if (MemCheckBlock->getParent()->hasOptSize() || OptForSizeBasedOnProfile) {


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83329





More information about the llvm-commits mailing list