[DAGCombine] Poison-prove scalarizeExtractedVectorLoad.
authorFlorian Hahn <flo@fhahn.com>
Sat, 29 May 2021 17:50:14 +0000 (18:50 +0100)
committerFlorian Hahn <flo@fhahn.com>
Sun, 30 May 2021 10:40:55 +0000 (11:40 +0100)
commit126f90b252509486eab5bfbe06894805b26c8da2
tree3cb33bcb1aedb676a1f889a4326085bbc5110beb
parent71acce68daf4987529bf08d81a9c5d396536d7c4
[DAGCombine] Poison-prove scalarizeExtractedVectorLoad.

extractelement is poison if the index is out-of-bounds, so just
scalarizing the load may introduce an out-of-bounds load, which is UB.

To avoid introducing new UB, we can mask the index so it only contains
valid indices.

Fixes PR50382.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D103077
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/AArch64/arm64-indexed-vector-ldst.ll
llvm/test/CodeGen/SystemZ/vec-extract-02.ll
llvm/test/CodeGen/X86/vecloadextract.ll