[InstCombine] Try to narrow expr if trunc cannot be removed.
authorFlorian Hahn <flo@fhahn.com>
Fri, 3 Jul 2020 19:22:51 +0000 (20:22 +0100)
committerFlorian Hahn <flo@fhahn.com>
Fri, 3 Jul 2020 19:22:51 +0000 (20:22 +0100)
commit31971ca1c6f42aa9a5e162d63528b9709448f8d9
tree464e32479a62f78fb9163cd2c813825d3fc85dbb
parent71d88cebfb42c8c5ac2d54b42afdcca956e55660
[InstCombine] Try to narrow expr if trunc cannot be removed.

Narrowing an input expression of a truncate to a type larger than the
result of the truncate won't allow removing the truncate, but it may
enable further optimizations, e.g. allowing for larger vectorization
factors.

For now this is intentionally limited to integer types only, to avoid
producing new vector ops that might not be suitable for the target.

If we know that the only user is a trunc, we can also be allow more
cases, e.g. also shortening expressions with some additional shifts.

I would appreciate feedback on the best place to do such a narrowing.

This fixes PR43580.

Reviewers: spatel, RKSimon, lebedev.ri, xbolva00

Reviewed By: lebedev.ri

Differential Revision: https://reviews.llvm.org/D82973
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/test/Transforms/InstCombine/trunc-binop-ext.ll