[PATCH] D134382: [RISCV] Disallow scale for scatter/gather

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 21 13:18:58 PDT 2022


reames created this revision.
reames added reviewers: craig.topper, asb, kito-cheng.
Herald added subscribers: sunshaoce, VincentWu, StephenFan, vkmr, frasercrmck, ecnelises, evandro, luismarques, apazos, sameer.abuasal, steven.zhang, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, bollu, JDevlieghere, simoncook, johnrusso, rbar, hiraditya, arichardson, mcrosier.
Herald added a project: All.
reames requested review of this revision.
Herald added subscribers: pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.

RISCV doesn't actually support a scaled form of indexed load and store.  We previously handled this by forming the scaled SDNode, and then doing custom legalization during lowering.  This patch instead adds a callback via TLI to prevent formation entirely.

This has two effects:

- First, the GEP gets expanded (and used).  Instead of the shift being created with an SDLoc of the memory operation, it has the SDLoc of the GEP instruction.  This avoids the scheduler perturbing IR order when there's no reason to.
- Second, we fix what appears to be a bug in index calculation with RV32.  The rules for GEPs require index calculation be done in particular bitwidth, and it appears the custom legalization code got this wrong for the case where index type exceeds pointer width.  (Or at least, I trust the generic GEP lowering to be correct a lot more.)

The DAGCombiner change to handle VPScatter/VPGather is technically separate, but is required to prevent a regression on those intrinsics.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134382

Files:
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.h
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-scatter.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-vpgather.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-vpscatter.ll
  llvm/test/CodeGen/RISCV/rvv/mgather-sdnode.ll
  llvm/test/CodeGen/RISCV/rvv/mscatter-sdnode.ll
  llvm/test/CodeGen/RISCV/rvv/vpgather-sdnode.ll
  llvm/test/CodeGen/RISCV/rvv/vpscatter-sdnode.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134382.461991.patch
Type: text/x-patch
Size: 178597 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220921/46c1f205/attachment.bin>


More information about the llvm-commits mailing list