HomePhabricator

[VectorCombine] transform bitcasted shuffle to narrower elements

Authored by spatel on Apr 2 2020, 10:21 AM.

Description

[VectorCombine] transform bitcasted shuffle to narrower elements

bitcast (shuf V, MaskC) --> shuf (bitcast V), MaskC'

We do not attempt this in InstCombine because we do not want to change
types and create new shuffle ops that are potentially not lowered as
well as the original code. Here, we can check the cost model to see if
it is worthwhile.

I've aggressively enabled this transform even if the types are the same
size and/or equal cost because moving the bitcast allows InstCombine to
make further simplifications.

In the motivating cases from PR35454:
https://bugs.llvm.org/show_bug.cgi?id=35454
...this is enough to let instcombine and the backend eliminate the
redundant shuffles, but we probably want to extend VectorCombine to
handle the inverse pattern (shuffle-of-bitcast) to get that
simplification directly in IR.

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

Details

Committed
spatelApr 2 2020, 10:30 AM
Differential Revision
D76727: [VectorCombine] transform bitcasted shuffle to narrower elements
Parents
rGf2334a7ef255: [AMDGPU] Fix crash in SILoadStoreOptimizer
Branches
Unknown
Tags
Unknown