This is an archive of the discontinued LLVM Phabricator instance.

[LV][near-NFC] move isLegalMasked* from LoopVectorizationLegality to LoopVectorizationCostModel
AbandonedPublic

Authored by hsaito on Feb 7 2018, 6:17 PM.

Details

Summary

Please see RFC http://lists.llvm.org/pipermail/llvm-dev/2018-January/120164.html and follow up discussions for details.

Decision on whether to allow emulated masked load/store in loop vectorization is moved from legality to cost model
since it actually is a cost model question.

As I have suspected, cost model for emulated masked load/store doesn't seem to be reasonable.
We were allowing only one emulated masked store, and with very favorable cost model (i.e., cost is super low in my opinion).

As such, I've added cost model hacks to make the patch reasonably near NFC. It should result in the same cost model
computation as before for the cases where the loop was previously considered legal. The cost is artificially very high for
the cases where the loop was previously dropped from vectorization.

Move of isLegalMasked*() should be no-brainer. More controversial aspect of this patch is the cost model "hack"
to make this nearly NFC. If you do not like how it is done, please suggest constructive alternatives. Please do not
make "tune the cost model correctly" as a requirement for this patch to go in. That's a totally different activity from
making LV's architecture more modular. I hope somebody else can work on it.

Previous Steps in making LV more modular.
https://reviews.llvm.org/D41045
https://reviews.llvm.org/D41420

Diff Detail

Event Timeline

hsaito created this revision.Feb 7 2018, 6:17 PM
hsaito added inline comments.Feb 7 2018, 6:29 PM
lib/Transforms/Vectorize/LoopVectorize.cpp
6199

Does anyone want to keep this? This is the reason why I didn't bother making sure the same message will come out when we bail out here.

6606

If discount logic is applied, higher cost computed in getMemInstScalarizationCost() is thrown away.

6608

NumPredStores here is needed for the following LIT tests. They expect computation of values to be stored also being scalarized, and the "discount" function does that work.

Transforms/LoopVectorize/AArch64/predication_costs.ll
Transforms/LoopVectorize/float-induction.ll
Transforms/LoopVectorize/if-pred-stores.ll

test/Transforms/LoopVectorize/conditional-assignment.ll
4

I think we need to fix the missed analysis message so that it start with "loop not vectorized: ".
That would be a separate patch.

hsaito abandoned this revision.Feb 8 2018, 10:37 AM

The change at Line 6608 is good to minimize LIT test failures, but had a negative impact elsewhere. Ouch. More "tuning" needed.