This is an archive of the discontinued LLVM Phabricator instance.

[SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model min/max (PR44668)
ClosedPublic

Authored by lebedev.ri on Jan 30 2020, 1:57 PM.

Details

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 PR44668.

Diff Detail

Event Timeline

lebedev.ri created this revision.Jan 30 2020, 1:57 PM

Ping @reames / @mkazantsev
Please do indicate if there is any way i can help move this process along.
Thanks

This revision is now accepted and ready to land.Feb 24 2020, 10:07 PM

LGTM

Thank you for the review.

Rebased, NFC.

This revision was automatically updated to reflect the committed changes.
samparker added inline comments.
llvm/lib/Analysis/ScalarEvolutionExpander.cpp
2300

I'm a bit concerned about getOperationCost not really returning something useful, so how about getCmpSelInstrCost instead?

samparker added inline comments.Mar 4 2020, 6:31 AM
llvm/lib/Analysis/ScalarEvolutionExpander.cpp
2288

getArithmeticInstrCost?

lebedev.ri added inline comments.Mar 7 2020, 8:16 AM
llvm/lib/Analysis/ScalarEvolutionExpander.cpp
2288

Will reply in D73501