This is an archive of the discontinued LLVM Phabricator instance.

[FuncSpec] Split the specialization bonus into CodeSize and Latency.
ClosedPublic

Authored by labrinea on Jul 12 2023, 11:04 AM.

Details

Summary

Currently we use a combined metric TargetTransformInfo::TCK_SizeAndLatency
when estimating the specialization bonus. This is suboptimal, and in some
cases erroneous. For example we shouldn't be weighting the codesize decrease
attributed to constant propagation by the block frequency of the dead code.
Instead only the latency savings should be weighted by block frequency. The
total codesize savings from all the specialization arguments should be
deducted from the specialization cost.

Diff Detail

Event Timeline

labrinea created this revision.Jul 12 2023, 11:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2023, 11:04 AM
labrinea requested review of this revision.Jul 12 2023, 11:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2023, 11:04 AM
ChuanqiXu accepted this revision.Jul 13 2023, 1:12 AM

Sounds good.

This revision is now accepted and ready to land.Jul 13 2023, 1:12 AM
labrinea added a comment.EditedJul 13 2023, 7:35 AM

I run some experiments to measure compilation time. It seems if getUserBonus returns std::pair<Cost,Cost> instead of caching CodeSize and Latency to the InstCostVisitor it is slightly faster (perhaps a litle uglier too).
This patch improves geomean of instruction count for llvm-test-suite by -0.016% at O3 and regresses it by +0.07% at LTO. The alternative is -0.036 and +0.064% respectively.

labrinea updated this revision to Diff 540379.Jul 14 2023, 5:39 AM

This revision is better in compile times (instruction count) for llvm test suite: Geomean with O3 is -0.049%, with LTO is +0.062%.

labrinea requested review of this revision.Jul 14 2023, 5:40 AM
labrinea updated this revision to Diff 542845.Jul 21 2023, 3:11 AM

Improved the description of estimateBasicBlocks

This revision is now accepted and ready to land.Jul 25 2023, 11:55 PM
This revision was landed with ongoing or failed builds.Jul 26 2023, 4:07 AM
This revision was automatically updated to reflect the committed changes.