[SLP] sort candidates to increase chance of optimal compare reduction
authorSanjay Patel <spatel@rotateright.com>
Thu, 17 Sep 2020 12:39:23 +0000 (08:39 -0400)
committerSanjay Patel <spatel@rotateright.com>
Thu, 17 Sep 2020 12:49:27 +0000 (08:49 -0400)
commit03783f19dc78fc45fd987f892c314578b5e52d78
treeeef2370174e0359bddcd49edd453f381eb731666
parent788c7d2ec11dfc868a5b03478c922dc9699c6d47
[SLP] sort candidates to increase chance of optimal compare reduction

This is one (small) part of improving PR41312:
https://llvm.org/PR41312

As shown there and in the smaller tests here, if we have some member of the
reduction values that does not match the others, we want to push it to the
end (bring the matching members forward and together).

In the regression tests, we have 5 candidates for the 4 slots of the reduction.
If the one "wrong" compare is grouped with the others, it prevents forming the
ideal v4i1 compare reduction.

Differential Revision: https://reviews.llvm.org/D87772
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/X86/compare-reduce.ll