[DAGCombine] reduceBuildVecToShuffle(): sort input vectors by decreasing size
authorRoman Lebedev <lebedev.ri@gmail.com>
Mon, 14 Jun 2021 12:59:03 +0000 (15:59 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Mon, 14 Jun 2021 13:18:37 +0000 (16:18 +0300)
commit6e5628354e22f3ca40b04295bac540843b8e6482
treed666f9c768b8f692e8eed365b1d2f4c8fbafd9c9
parent85208b96b85f6f3e502cf4b7fd5f440434d1c7e5
[DAGCombine] reduceBuildVecToShuffle(): sort input vectors by decreasing size

The sorting, obviously, must be stable, else we will have random assembly fluctuations.

Apparently there was no test coverage that would benefit from that,
so i've added one test.

The sorting consists of two parts - just sort the input vectors,
and recompute the shuffle mask -> input vector mapping.
I don't believe we need to do anything else.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D104187
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/X86/oddshuffles.ll