[RISCV] Add a pass to recognize VLS strided loads/store from gather/scatter.
authorCraig Topper <craig.topper@sifive.com>
Mon, 20 Sep 2021 16:31:14 +0000 (09:31 -0700)
committerCraig Topper <craig.topper@sifive.com>
Mon, 20 Sep 2021 16:39:44 +0000 (09:39 -0700)
commitd85e347a28dc9a329d7029987e4e062428985b41
tree98057de6c54d47836073b87ac7e454fd964fe735
parentd001ab82e410d0c6ccf14be9f507c8aca53abc67
[RISCV] Add a pass to recognize VLS strided loads/store from gather/scatter.

For strided accesses the loop vectorizer seems to prefer creating a
vector induction variable with a start value of the form
<i32 0, i32 1, i32 2, ...>. This value will be incremented each
loop iteration by a splat constant equal to the length of the vector.
Within the loop, arithmetic using splat values will be done on this
vector induction variable to produce indices for a vector GEP.

This pass attempts to dig through the arithmetic back to the phi
to create a new scalar induction variable and a stride. We push
all of the arithmetic out of the loop by folding it into the start,
step, and stride values. Then we create a scalar GEP to use as the
base pointer for a strided load or store using the computed stride.
Loop strength reduce will run after this pass and can do some
cleanups to the scalar GEP and induction variable.

Reviewed By: frasercrmck

Differential Revision: https://reviews.llvm.org/D107790
llvm/include/llvm/IR/IntrinsicsRISCV.td
llvm/lib/Target/RISCV/CMakeLists.txt
llvm/lib/Target/RISCV/RISCV.h
llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp [new file with mode: 0644]
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.h
llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
llvm/test/CodeGen/RISCV/rvv/fixed-vector-strided-load-store-negative.ll [new file with mode: 0644]
llvm/test/CodeGen/RISCV/rvv/fixed-vector-strided-load-store.ll [new file with mode: 0644]
llvm/tools/opt/opt.cpp