[DAG] visitINSERT_VECTOR_ELT - refactor BUILD_VECTOR creation from INSERT_VECTOR_ELT...
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 16 Jul 2022 15:37:31 +0000 (16:37 +0100)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 16 Jul 2022 15:37:31 +0000 (16:37 +0100)
commita44bdf9bc147af5c8e2b66764a1d33cce39a34b6
tree9ff6db3c61ab4e9a64f6d05e25de9d0cb14a3b76
parent52b6168c167e3b22823a1ff09dd00859ef7c2768
[DAG] visitINSERT_VECTOR_ELT - refactor BUILD_VECTOR creation from INSERT_VECTOR_ELT chain.

D127595 added the ability to recurse up a (one-use) INSERT_VECTOR_ELT chain to create a BUILD_VECTOR before other combines manage to break the chain, something that is particularly bad in D127115.

The patch generalises this so it doesn't have to build the chain starting from the last element insertion, instead it can now start from any insertion and will recurse up the chain until it finds all elements or finds a UNDEF/BUILD_VECTOR/SCALAR_TO_VECTOR which represents that start of the chain.

Fixes several regressions in D127115
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp