Please see http://lists.llvm.org/pipermail/llvm-dev/2018-January/120164.html for RFC and the discussions.
All SIMD architectures can emulate masked load/store/gather/scatter through element-wise condition check, scalar load/store, and insert/extract. Therefore, bailing out of vectorization as legality failure, when they return false, is incorrect. We should proceed to cost model and determine profitability.
This patch is to address the vectorizer's architectural limitation described above. As such, I tried to keep the cost model and vectorize/don't-vectorize behavior nearly unchanged. Cost model tuning should be done separately.
dyn_cast<> abuse fixed. Code simplified a bit. Should be NFC.