[InstCombine] try to convert vector insert+extract to trunc
authorSanjay Patel <spatel@rotateright.com>
Sun, 30 Sep 2018 14:34:01 +0000 (14:34 +0000)
committerSanjay Patel <spatel@rotateright.com>
Sun, 30 Sep 2018 14:34:01 +0000 (14:34 +0000)
commit1e0f1f645a649a5a453742c4ca10aa0816d3fc0a
tree63b371c09696dab00e8a879f0958ee5183cfece1
parent26c119a9c2f1d6866fe5996ef5a039b4fc3749ca
[InstCombine] try to convert vector insert+extract to trunc

This transform is requested for the backend in:
https://bugs.llvm.org/show_bug.cgi?id=39016
...but I figured it was worth doing in IR too, and it's probably
easier to implement here, so that's this patch.

In the simplest case, we are just truncating a scalar value. If the
extract index doesn't correspond to the LSBs of the scalar, then we
have to shift-right before the truncate. Endian-ness makes this tricky,
but hopefully the ASCII-art helps visualize the transform.

Differential Revision: https://reviews.llvm.org/D52439

llvm-svn: 343407
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
llvm/test/Transforms/InstCombine/extractelement.ll