[CodeGen] Don't combine extract + concat vectors with non-legal types
authorTies Stuij <ties.stuij@arm.com>
Wed, 8 Jul 2020 12:12:30 +0000 (13:12 +0100)
committerTies Stuij <ties.stuij@arm.com>
Wed, 8 Jul 2020 14:29:57 +0000 (15:29 +0100)
commit26a22478cdfe6fe4d169320910c38958d5dafc38
treedeace0cdb68f0da1dc0f805ee7afa087460d1691
parentea8bba7e8d0db3541a386ad649c4bf21d53e8380
[CodeGen] Don't combine extract + concat vectors with non-legal types

Summary:
The following combine currently breaks in the DAGCombiner:

```
extract_vector_elt (concat_vectors v4i16:a, v4i16:b), x
   -> extract_vector_elt a, x
```

This happens because after we have combined these nodes we have inserted nodes
that use individual instances of the vector element type. In the above example
i16. However this isn't a legal type on all backends, and when the combining pass calls
the legalizer it breaks as it expects types to already be legal. The type legalizer has
already been run, and running it again would make a mess of the nodes.

In the example code at least, the generated code is still efficient after the change.

Reviewers: miyuki, arsenm, dmgreen, lebedev.ri

Reviewed By: miyuki, lebedev.ri

Subscribers: lebedev.ri, wdng, hiraditya, steven.zhang, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D83231
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/AArch64/regress-combine-extract-vectors.ll [new file with mode: 0644]