[InstCombine] add casts from splat-a-bit pattern if necessary
authorChenbing Zheng <Chenbing.Zheng@streamcomputing.com>
Sat, 7 May 2022 07:34:57 +0000 (15:34 +0800)
committerChenbing Zheng <Chenbing.Zheng@streamcomputing.com>
Sat, 7 May 2022 07:34:57 +0000 (15:34 +0800)
commit8eaa1ef0d88c36dbf90e191c8852ea46bf4841c9
tree1c741f158133558fa753b2a26d4f38691ba3ba62
parent83e07916ffc55dd85989726f991331c8ad1439d0
[InstCombine] add casts from splat-a-bit pattern if necessary

Splatting a bit of constant-index across a value:
sext (ashr (trunc iN X to iM), M-1) to iN --> ashr (shl X, N-M), N-1
If the dest type is different, use a cast (adjust use check).

https://alive2.llvm.org/ce/z/acAan3

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D124590
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/test/Transforms/InstCombine/sext.ll