[InstSimplify] fold splat of inserted constant to vector constant
authorSanjay Patel <spatel@rotateright.com>
Sun, 15 Dec 2019 14:32:03 +0000 (09:32 -0500)
committerSanjay Patel <spatel@rotateright.com>
Sun, 15 Dec 2019 14:32:03 +0000 (09:32 -0500)
commit6080387f136af5a51bbc310abb08c7158d7cd9d2
tree1ccdd02183bb684d7fb2e99249ff8e5e870875a2
parent2afe86411847b3305915f536256b8bb877d8a356
[InstSimplify] fold splat of inserted constant to vector constant

shuf (inselt ?, C, IndexC), undef, <IndexC, IndexC...> --> <C, C...>

This is another missing shuffle fold pattern uncovered by the
shuffle correctness fix from D70246.

The problem was visible in the post-commit thread example, but
we managed to overcome the limitation for that particular case
with D71220.

This is something like the inverse of the previous fix - there
we didn't demand the inserted scalar, and here we are only
demanding an inserted scalar.

Differential Revision: https://reviews.llvm.org/D71488
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstCombine/insert-extract-shuffle.ll
llvm/test/Transforms/InstSimplify/shufflevector.ll