This is an archive of the discontinued LLVM Phabricator instance.

[TTI] Add uniform/non-uniform constant Pow2 detection to TargetTransformInfo::getInstructionThroughput
ClosedPublic

Authored by RKSimon on May 9 2018, 5:56 AM.

Details

Summary

This enables us to detect more fast path sdiv cases under cost analysis (only LV currently use pow2 and only for uniform constants).

This patch also enables us to handle non-uniform-constant pow2 cases for X86 SDIV costs.

Found while working on D46276

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon created this revision.May 9 2018, 5:56 AM
ABataev added inline comments.May 15 2018, 7:22 AM
lib/Analysis/TargetTransformInfo.cpp
758 ↗(On Diff #145902)

I think it is better to move the result of statement from line 777 here rather than perform the same kind of analysis 2 times.

760–772 ↗(On Diff #145902)

This analysis should be guarded by the check of the OVP parameter if it is nullptr or not.

765 ↗(On Diff #145902)

The names of the variables should start from the capital letters.

RKSimon updated this revision to Diff 147793.May 21 2018, 8:42 AM

Updated based on feedback from @ABataev

RKSimon added inline comments.May 21 2018, 8:44 AM
lib/Analysis/TargetTransformInfo.cpp
760–772 ↗(On Diff #145902)

I tried that but it got rather messy. An alternative would be to make OVP a reference instead of a pointer, since its always used - what do you think?

ABataev added inline comments.May 21 2018, 8:47 AM
lib/Analysis/TargetTransformInfo.cpp
760–772 ↗(On Diff #145902)

Yes, I think it would be much better

RKSimon updated this revision to Diff 147800.May 21 2018, 9:23 AM

Use reference instead of a pointer in getOperandInfo

Is it possible to show a vectorizer before/after with this change? I worry that we risk losing the motivating case if we only have CostModel regression tests instead of actual IR diffs.

This revision is now accepted and ready to land.May 21 2018, 9:48 AM

Is it possible to show a vectorizer before/after with this change? I worry that we risk losing the motivating case if we only have CostModel regression tests instead of actual IR diffs.

Vectorizers tend to call getArithmeticInstrCost directly and don't pass through TargetTransformInfo::getInstructionThroughput/getInstructionCost - this patch is about improvements to the CostModel analysis pass to show that x86 is now aware of non-uniform pow2 SDIV special cases.

There is equivalent code in both Loopvectorize/SLPVectorizer that currently only recognise uniform power of 2 constants - I can fix these in future patches that should demonstrate IR diffs.

This revision was automatically updated to reflect the committed changes.