This is an archive of the discontinued LLVM Phabricator instance.

[LV] Ignore the cost of values that will not appear in the vectorized loop
ClosedPublic

Authored by dorit on Dec 6 2017, 12:43 AM.

Details

Summary

VecValuesToIgnore holds values that will not appear in the vectorized loop. We should therefore ignore their cost when VF > 1.
I think this bit was missed by https://reviews.llvm.org/D15177 which introduced the VecValuesToIgnore construct, but considered it only in register-usage calculation.

The testcase is taken from https://reviews.llvm.org/D12770 - is had redundant cases, and we check that the cost model ignores them.

Diff Detail

Repository
rL LLVM

Event Timeline

dorit created this revision.Dec 6 2017, 12:43 AM
fhahn added a subscriber: fhahn.Dec 6 2017, 2:10 AM
fhahn added a comment.EditedDec 6 2017, 2:23 AM

The comment next to the VecValuesToIgnore declaration explicitly states that those instructions should be skipped during cost modelling if VF > 1 (/// Values to ignore in the cost model when VF > 1.)

So this looks good to me, although someone else should probably sign-off too.

lib/Transforms/Vectorize/LoopVectorize.cpp
6869 ↗(On Diff #125674)

No curly braces here. I think this could even be merged with the previous check, as they both skip ignored values.

dorit updated this revision to Diff 125685.Dec 6 2017, 2:37 AM

Thanks Florian. Uploaded the formatting fix.

Ayal accepted this revision.Dec 9 2017, 1:57 PM

LGTM, thanks for taking this out of D38948 and into a separate commit.

lib/Transforms/Vectorize/LoopVectorize.cpp
6867 ↗(On Diff #125685)

Can add a comment that VecValuesToIgnore should also be skipped for VF == 1 and UF > 1, but expectedCost() provides only VF, where VF == 1 stands for the baseline version (with UF == 1 too).

Can add a comment to also have getSmallestAndWidestTypes() skip over VecValuesToIgnore, as it too only skips over ValuesToIgnore; although it only deals with loads/stores/phi's anyhow.

test/Transforms/LoopVectorize/X86/reduction-small-size.ll
23 ↗(On Diff #125685)

Add a CHECK that such estimates are found for VF 1?

This revision is now accepted and ready to land.Dec 9 2017, 1:57 PM
This revision was automatically updated to reflect the committed changes.