[PATCH] D73501: [SCEV] SCEVExpander::isHighCostExpansion(): perform actual cost-modelling (PR44668)

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 27 13:20:37 PST 2020


lebedev.ri created this revision.
lebedev.ri added reviewers: reames, mkazantsev, asbirlea, fhahn, skatkov.
lebedev.ri added a project: LLVM.
Herald added subscribers: dmgreen, javed.absar, zzheng, hiraditya.

The current `SCEVExpander::isHighCostExpansion()` is weird,
for example, it considers the `SCEVNAryExpr` itself  to not
be high-cost, but completely gives up on `SCEVMinMaxExpr`.

In PR44668 <https://bugs.llvm.org/show_bug.cgi?id=44668>,
that prevents `-indvars` from replacing uses of induction variable after the loop,
which might be one of the optimization failures preventing that code from being vectorized.

Instead, i think we should simply perform cost modelling
via `TargetTransformInfo::getOperationCost()`,
and pick //some// magical per-IV budget.
I think, `4` is a good guess. (For PR44668 i need at least `3`.)

I think, the cost modeling is pretty self-explanatory?
(Which may mean this is completely wrong..)

Thoughts?

Fixes PR44668 <https://bugs.llvm.org/show_bug.cgi?id=44668>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73501

Files:
  llvm/include/llvm/Analysis/ScalarEvolutionExpander.h
  llvm/include/llvm/Transforms/Utils/LoopUtils.h
  llvm/include/llvm/Transforms/Utils/SimplifyIndVar.h
  llvm/include/llvm/Transforms/Utils/UnrollLoop.h
  llvm/lib/Analysis/ScalarEvolutionExpander.cpp
  llvm/lib/Target/ARM/MVETailPredication.cpp
  llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
  llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp
  llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
  llvm/lib/Transforms/Utils/LoopUnroll.cpp
  llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp
  llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
  llvm/lib/Transforms/Utils/LoopUtils.cpp
  llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
  llvm/test/Transforms/IndVarSimplify/dont-recompute.ll
  llvm/test/Transforms/IndVarSimplify/elim-extend.ll
  llvm/test/Transforms/IndVarSimplify/eliminate-comparison.ll
  llvm/test/Transforms/IndVarSimplify/eliminate-trunc.ll
  llvm/test/Transforms/IndVarSimplify/full_widening.ll
  llvm/test/Transforms/IndVarSimplify/iv-widen.ll
  llvm/test/Transforms/IndVarSimplify/lftr-multi-exit.ll
  llvm/test/Transforms/IndVarSimplify/lftr-reuse.ll
  llvm/test/Transforms/IndVarSimplify/loop-invariant-conditions.ll
  llvm/test/Transforms/IndVarSimplify/lrev-existing-umin.ll
  llvm/test/Transforms/IndVarSimplify/pr28705.ll
  llvm/test/Transforms/IndVarSimplify/pr39673.ll
  llvm/test/Transforms/IndVarSimplify/widen-loop-comp.ll
  llvm/test/Transforms/LoopVectorize/X86/float-induction-x86.ll
  llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73501.240661.patch
Type: text/x-patch
Size: 113508 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200127/a5f379cf/attachment-0001.bin>


More information about the llvm-commits mailing list