[PATCH] D65060: [LICM] Make Loop ICM profile aware

Wenlei He via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 22 22:59:16 PDT 2019


wenlei added a comment.

In D65060#1596194 <https://reviews.llvm.org/D65060#1596194>, @davidxl wrote:

> Hal probably remembered more details. IIRC, the argument was that LICM provides IR canonicalization which can simplify analysis -- there were some examples about exposed vectorization opportunities etc.


I looked at the loop sink pass, and the case we ran into again. I think it'd be difficult for the loop sink pass to handle that case. There's a switch with over 200 case arms, inside a loop. Each case arm has a GEP, and the results of these GEP are merged into a phi outside of the switch, then used by a load afterwards. LICM hoisted all these 200+ GEP to the preheader. But since the use is after the switch, none of the original containing blocks (lower frequency switch arms) dominates the use block, so loop sink cannot sink these GEPs back as it can't find a set of blocks with lower frequency sum.

In D65060#1596210 <https://reviews.llvm.org/D65060#1596210>, @fhahn wrote:

> FWIW, LoopVectorize kind of expects invariant code to be hoisted out of the loop body before vectorization. We recently addressed some issues caused by stuff not being hoisted (D59995 <https://reviews.llvm.org/D59995>) and have some ideas on how to improve things on the LoopVectorize side a bit.


While It is not ideal to skip LICM as canonicalization, practically if loop sink can't undo some harmful hoisting, we have to do this to get around pathological cases. On the other hand, when some blocks from loop body is much colder than preheader, there's a good chance that we have non-trivial control flow inside loop, so the impact on vectorization might not be too big..

We could also tune the heuristic to be conservative - only skip hoisting when preheader is much hotter (e.g. >=4x). Thoughts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65060





More information about the llvm-commits mailing list