[SLP] match logical and/or as reduction candidates
authorSanjay Patel <spatel@rotateright.com>
Wed, 14 Jul 2021 13:02:31 +0000 (09:02 -0400)
committerSanjay Patel <spatel@rotateright.com>
Wed, 14 Jul 2021 13:02:31 +0000 (09:02 -0400)
commit25ee55c0baff316d3a7b1d7d2830a168af3fc46a
tree3c144e1d5536fe343eebca9870718412232a960f
parentbdf31471c76b5ded9e8d5a039250c2a7ba7aead6
[SLP] match logical and/or as reduction candidates

This has been a work-in-progress for a long time...we finally have all of
the pieces in place to handle vectorization of compare code as shown in:
https://llvm.org/PR41312

To do this (see PhaseOrdering tests), we converted SimplifyCFG and
InstCombine to the poison-safe (select) forms of the logic ops, so now we
need to have SLP recognize those patterns and insert a freeze op to make
a safe reduction:
https://alive2.llvm.org/ce/z/NH54Ah

We get the minimal patterns with this patch, but the PhaseOrdering tests
show that we still need adjustments to get the ideal IR in some or all of
the motivating cases.

Differential Revision: https://reviews.llvm.org/D105730
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/PhaseOrdering/X86/vector-reductions-logical.ll
llvm/test/Transforms/SLPVectorizer/X86/reduction-logical.ll