Skip to content

Commit f36fba9

Browse files
committed
Address review comments
1 parent ea2c9b0 commit f36fba9

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

llvm/lib/Target/RISCV/RISCVInterleavedAccess.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,21 @@ static bool isMultipleOfN(const Value *V, const DataLayout &DL, unsigned N) {
102102
return false;
103103
}
104104

105-
static bool getMemOperands(IRBuilderBase &Builder, unsigned Factor,
106-
VectorType *VTy, const DataLayout &DL, Type *XLenTy,
105+
/// Do the common operand retrieval and validition required by the
106+
/// routines below.
107+
static bool getMemOperands(unsigned Factor,
108+
VectorType *VTy, Type *XLenTy,
107109
Instruction *I, Value *&Ptr, Value *&Mask,
108110
Value *&VL, Align &Alignment) {
111+
112+
IRBuilder<> Builder(I);
113+
const DataLayout &DL = I->getDataLayout();
109114
ElementCount EC = VTy->getElementCount();
110115
if (auto *LI = dyn_cast<LoadInst>(I)) {
111116
assert(LI->isSimple());
112117
Ptr = LI->getPointerOperand();
113118
Alignment = LI->getAlign();
114-
assert(!Mask && "Unexpected mask on a load\n");
119+
assert(!Mask && "Unexpected mask on a load");
115120
Mask = Builder.getAllOnesMask(EC);
116121
VL = isa<FixedVectorType>(VTy) ? Builder.CreateElementCount(XLenTy, EC)
117122
: Constant::getAllOnesValue(XLenTy);
@@ -135,7 +140,7 @@ static bool getMemOperands(IRBuilderBase &Builder, unsigned Factor,
135140
Alignment = VPLdSt->getPointerAlignment().value_or(
136141
DL.getABITypeAlign(VTy->getElementType()));
137142

138-
assert(Mask && "vp.load needs a mask!");
143+
assert(Mask && "vp.load and vp.store needs a mask!");
139144

140145
Value *WideEVL = VPLdSt->getVectorLengthParam();
141146
// Conservatively check if EVL is a multiple of factor, otherwise some
@@ -173,7 +178,7 @@ bool RISCVTargetLowering::lowerInterleavedLoad(
173178

174179
Value *Ptr, *VL;
175180
Align Alignment;
176-
if (!getMemOperands(Builder, Factor, VTy, DL, XLenTy, Load, Ptr, Mask, VL,
181+
if (!getMemOperands(Factor, VTy, XLenTy, Load, Ptr, Mask, VL,
177182
Alignment))
178183
return false;
179184

@@ -319,7 +324,7 @@ bool RISCVTargetLowering::lowerDeinterleaveIntrinsicToLoad(
319324

320325
Value *Ptr, *VL;
321326
Align Alignment;
322-
if (!getMemOperands(Builder, Factor, ResVTy, DL, XLenTy, Load, Ptr, Mask, VL,
327+
if (!getMemOperands(Factor, ResVTy, XLenTy, Load, Ptr, Mask, VL,
323328
Alignment))
324329
return false;
325330

@@ -383,7 +388,7 @@ bool RISCVTargetLowering::lowerInterleaveIntrinsicToStore(
383388

384389
Value *Ptr, *VL;
385390
Align Alignment;
386-
if (!getMemOperands(Builder, Factor, InVTy, DL, XLenTy, Store, Ptr, Mask, VL,
391+
if (!getMemOperands(Factor, InVTy, XLenTy, Store, Ptr, Mask, VL,
387392
Alignment))
388393
return false;
389394
Type *PtrTy = Ptr->getType();

0 commit comments

Comments
 (0)