This is an archive of the discontinued LLVM Phabricator instance.

[TTI] `BasicTTIImplBase::getInterleavedMemoryOpCost()`: fix load discounting
ClosedPublic

Authored by lebedev.ri on Oct 22 2021, 2:43 AM.

Details

Summary

The math here is:
Cost of 1 load = cost of n loads / n
Cost of live loads = num live loads * Cost of 1 load
Cost of live loads = num live loads * (cost of n loads / n)
Cost of live loads = cost of n loads * (num live loads / n)

But, all the variables here are integers,
and integer division rounds down,
but this calculation clearly expects float semantics.

Instead multiply upfront, and then perform round-up-division.

Diff Detail

Event Timeline

lebedev.ri requested review of this revision.Oct 22 2021, 2:43 AM
lebedev.ri created this revision.
RKSimon accepted this revision.Oct 22 2021, 3:56 AM

Good Catch! LGTM

This revision is now accepted and ready to land.Oct 22 2021, 3:56 AM

Good Catch! LGTM

Thank you for the review!

This revision was landed with ongoing or failed builds.Oct 22 2021, 4:09 AM
This revision was automatically updated to reflect the committed changes.