[VPlan] Only generate single instr for loads uniform across all parts.
authorFlorian Hahn <flo@fhahn.com>
Thu, 8 Sep 2022 13:27:58 +0000 (14:27 +0100)
committerFlorian Hahn <flo@fhahn.com>
Thu, 8 Sep 2022 13:27:58 +0000 (14:27 +0100)
commit422cf99161ed5c34a32ce9ad549b5da29ad7906f
treef9b8c7feafc8eee1f459ff1796a0af6824d924d5
parent7d4ee32662e42093024fa1c7c1103f7484d080c1
[VPlan] Only generate single instr for loads uniform across all parts.

VPReplicateRecipe::isUniform actually means uniform-per-parts, hence a
scalar instruction is generated per-part.

This is a potential alternative D132892. For now the current patch only
catches cases where the address is trivially invariant (defined outside
VPlan), while D132892 catches any address that is considered invariant
by SCEV AFAICT.

It should be possible to hoist fully invariant recipes feeding loads out
of the vector loop region as well, but in practice LICM should do that
already.

This version of the patch artificially limits this to loads to make it
easier to compare, but this restriction should be easily liftable.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D133019
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/RISCV/uniform-load-store.ll
llvm/test/Transforms/LoopVectorize/X86/cost-model-assert.ll
llvm/test/Transforms/LoopVectorize/X86/uniform_mem_op.ll
llvm/test/Transforms/LoopVectorize/induction.ll
llvm/test/Transforms/LoopVectorize/pointer-select-runtime-checks.ll