[SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model min/max (PR44668)
authorRoman Lebedev <lebedev.ri@gmail.com>
Tue, 25 Feb 2020 18:52:46 +0000 (21:52 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Tue, 25 Feb 2020 20:05:59 +0000 (23:05 +0300)
commitd6f47aeb5198b142072d8ce2bbf2fdd30d116db0
tree6af8e9b1ccb536c903cadbc6c7420382dac41252
parent0f3c9b54e60b384728c0c24518b8f2645719275e
[SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model min/max (PR44668)

Summary:
Previosly we simply always said that `SCEVMinMaxExpr` is too costly to expand.
But this isn't really true, it expands into just a comparison+swap pair.
And again much like with add/mul, there will be one less such pair
than the number of operands. And we need to count the cost of operands themselves.

This does change a number of testcases, and as far as i can tell,
all of these changes are improvements, in the sense that
we fixed up more latches to do the [in]equality comparison.

This concludes cost-modelling changes, no other SCEV expressions exist as of now.

This is a part of addressing [[ https://bugs.llvm.org/show_bug.cgi?id=44668 | PR44668 ]].

Reviewers: reames, mkazantsev, wmi, sanjoy

Reviewed By: mkazantsev

Subscribers: hiraditya, javed.absar, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73744
llvm/lib/Analysis/ScalarEvolutionExpander.cpp
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/widen-loop-comp.ll
llvm/test/Transforms/LoopVectorize/X86/float-induction-x86.ll