[DAG] Fold extract_vector_elt (scalar_to_vector), K to undef (K != 0)
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 21 Jan 2020 10:56:55 +0000 (10:56 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 21 Jan 2020 10:58:30 +0000 (10:58 +0000)
commit5f5f4785648959dfbb5c88d183816f85a0974561
treeb808fb591dd064cc76c5818aa52a35ca6ff7ba40
parentd6f4cfdbd7923bae74d4a45f276f3b7f3e053f39
[DAG] Fold extract_vector_elt (scalar_to_vector), K to undef (K != 0)

This was unconditionally folding this to the source operand, even if the access was out of bounds. Use undef instead of the extract is not the first element.

This helps with some cases where 3-vectors are legalized and avoids processing the 4th component.

Original Patch by: arsenm (Matt Arsenault)

Differential Revision: https://reviews.llvm.org/D51589
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/AMDGPU/cvt_f32_ubyte.ll
llvm/test/CodeGen/AMDGPU/max.i16.ll