[llvm] [IA][RISCV] Add support for vp.load/vp.store with shufflevector (PR #135445)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Wed May 7 02:27:22 PDT 2025
================
@@ -454,27 +496,77 @@ bool InterleavedAccessImpl::tryReplaceExtracts(
}
bool InterleavedAccessImpl::lowerInterleavedStore(
- StoreInst *SI, SmallSetVector<Instruction *, 32> &DeadInsts) {
- if (!SI->isSimple())
- return false;
+ Instruction *Store, SmallSetVector<Instruction *, 32> &DeadInsts) {
+ Value *StoredValue;
+ if (auto *SI = dyn_cast<StoreInst>(Store)) {
+ if (!SI->isSimple())
+ return false;
+ StoredValue = SI->getValueOperand();
+ } else if (auto *VPStore = dyn_cast<VPIntrinsic>(Store)) {
+ assert(VPStore->getIntrinsicID() == Intrinsic::vp_store);
+ // Require a constant mask.
+ if (!isa<ConstantVector>(VPStore->getArgOperand(2)))
+ return false;
+ StoredValue = VPStore->getArgOperand(0);
+ } else {
+ llvm_unreachable("unsupported store operation");
+ }
- auto *SVI = dyn_cast<ShuffleVectorInst>(SI->getValueOperand());
+ auto *SVI = dyn_cast<ShuffleVectorInst>(StoredValue);
if (!SVI || !SVI->hasOneUse() || isa<ScalableVectorType>(SVI->getType()))
return false;
+ unsigned NumStoredElements =
+ cast<FixedVectorType>(SVI->getType())->getNumElements();
// Check if the shufflevector is RE-interleave shuffle.
unsigned Factor;
if (!isReInterleaveMask(SVI, Factor, MaxFactor))
return false;
+ assert(NumStoredElements % Factor == 0 &&
+ "number of stored element should be a multiple of Factor");
+
+ if (auto *VPStore = dyn_cast<VPIntrinsic>(Store)) {
+ unsigned LaneMaskLen = NumStoredElements / Factor;
+ Value *LaneMask = getMask(VPStore->getArgOperand(2), Factor,
----------------
lukel97 wrote:
```suggestion
Value *LaneMask = getMask(VPStore->getMaskParam(), Factor,
```
https://github.com/llvm/llvm-project/pull/135445
More information about the llvm-commits
mailing list