Fix SLPVectorizer commutativity reordering
authorMehdi Amini <mehdi.amini@apple.com>
Fri, 6 Nov 2015 20:17:51 +0000 (20:17 +0000)
committerMehdi Amini <mehdi.amini@apple.com>
Fri, 6 Nov 2015 20:17:51 +0000 (20:17 +0000)
commit7d84928143c32280d63d7c6dbcfebc2df607baff
tree3f8b5338179e3efac0a59518a0925864ad0dbfed
parent91950eea5582709ea263cc48bd97fdea817b53d1
Fix SLPVectorizer commutativity reordering

The SLPVectorizer had a very crude way of trying to benefit
from associativity: it tried to optimize for splat/broadcast
or in order to have the same operator on the same side.
This is benefitial to the cost model and allows more vectorization
to occur.
This patch improve the logic and make the detection optimal (locally,
we don't look at the full tree but only at the immediate children).

Should fix https://llvm.org/bugs/show_bug.cgi?id=25247

Reviewers: mzolotukhin

Differential Revision: http://reviews.llvm.org/D13996

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252337 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Vectorize/SLPVectorizer.cpp
test/Transforms/SLPVectorizer/X86/commutativity.ll [new file with mode: 0644]