[SVE] Don't reorder subvector/binop sequences when the resulting binop is not legal.
authorPaul Walker <paul.walker@arm.com>
Fri, 21 Aug 2020 12:38:55 +0000 (13:38 +0100)
committerPaul Walker <paul.walker@arm.com>
Wed, 2 Sep 2020 10:01:33 +0000 (11:01 +0100)
commitf72121254da48bf668c35918b53c96cf8c568342
tree64ecaee9167ffd83da2ecea97c9b755ef21e091c
parent4bdab2e86aba371dbad100dd3515ab9f05833719
[SVE] Don't reorder subvector/binop sequences when the resulting binop is not legal.

When lowering fixed length vector operations for SVE the subvector
operations are used extensively to marshall data between scalable
and fixed-length vectors. This means that sequences like:

  extract_subvec(binop(insert_subvec(a), insert_subvec(b)))

are very common. DAGCombine only checks if the resulting binop is
legal or can be custom lowered when undoing such sequences. When
it's custom lowering that is introducing them the result is an
infinite legalise->combine->legalise loop.

This patch extends the isOperationLegalOr... functions to include
a "LegalOnly" parameter to restrict the check to legal operations
only. Although isOperationLegal could be used it's common for
the affected code paths to be visited pre and post legalisation,
so the extra parameter keeps the code tidy.

Differential Revision: https://reviews.llvm.org/D86450
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/AArch64/sve-fixed-length-subvector.ll