[PATCH] D85784: [PGO][PGSO][LV] Fix loop not vectorized issue under profile guided size opts.

Hiroshi Yamauchi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 17 13:00:39 PDT 2020


yamauchi added a comment.

In D85784#2211641 <https://reviews.llvm.org/D85784#2211641>, @davidxl wrote:

> If shouldOptimizeForSize is not available for loop analysis, should the check of be removed unconditionally instead of gated upon whether there is a hint?

I think no, as it'd be an unintended removal of this piece of PGSO, which can be avoided by this patch.

Here's a longer description of my understanding.

D81345 <https://reviews.llvm.org/D81345> changed the vectorization scheme for -Os from "vectorization with versioning" to "vectorization without versioning" (saving some code size). It didn't change the fact that the explicit vectorization (via the pragma) takes precedence over the -Os flag (ie. still vectorize with pragma even with -Os.) But as it moved the size opt check (hasOptSize) from LoopVectorize.cpp to LoopAccessAnalysis.cpp (by not collecting stride accesses for hasOptSize cases earlier in LoopAccessAnalysis), but does not do similar for the PGSO cases (which is not easy), it inadvertently changed it so that the explicit vectorization does **no longer** take precedence over PGSO (as it removes the "Hints.getForce() != LoopVectorizeHints::FK_Enabled" check.) This is the unintended behavior change that's manifested as (internal) b/163165125.

Since shouldOptimizeForSize is not available for loop analysis (due to the stated reasons), this patch simply recovers the old behavior just under PGSO, which is "vectorize with versioning" if explicitly enabled, rather than "not vectorize" (which is unexpected), while keeping the new behavior for -Os.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85784



More information about the llvm-commits mailing list