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
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.