[SLP] Limit GEP lists based on width of index computation.
authorFlorian Hahn <flo@fhahn.com>
Wed, 24 Jun 2020 16:04:45 +0000 (17:04 +0100)
committerFlorian Hahn <flo@fhahn.com>
Wed, 24 Jun 2020 18:56:53 +0000 (19:56 +0100)
commit35bb9bfbb099eb78dbed8f96d7cd7f5506d6584f
treed065b56f504b92603fea52a0e9063c5452cc95b9
parentd65cdb498f901d7ce03dbaa1831c629400ebb422
[SLP] Limit GEP lists based on width of index computation.

D68667 introduced a tighter limit to the number of GEPs to simplify
together. The limit was based on the vector element size of the pointer,
but the pointers themselves are not actually put in vectors.

IIUC we try to vectorize the index computations here, so we should base
the limit on the vector element size of the computation of the index.

This restores the test regression on AArch64 and also restores the
vectorization for a important pattern in SPEC2006/464.h264ref on
AArch64 (@test_i16_extend). We get a large benefit from doing a single
load up front and then processing the index computations in vectors.

Note that we could probably even further improve the AArch64 codegen, if
we would do zexts to i32 instead of i64 for the sub operands and then do
a single vector sext on the result of the subtractions. AArch64 provides
dedicated vector instructions to do so. Sketch of proof in Alive:
https://alive2.llvm.org/ce/z/A4xYAB

Reviewers: craig.topper, RKSimon, xbolva00, ABataev, spatel

Reviewed By: ABataev, spatel

Differential Revision: https://reviews.llvm.org/D82418
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/AArch64/getelementptr.ll