-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[RISCV][IA] Use strided load for one active deinterleaveN(load) #148892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -243,20 +243,44 @@ bool RISCVTargetLowering::lowerDeinterleaveIntrinsicToLoad( | |||||||||
assert(LI->isSimple()); | ||||||||||
IRBuilder<> Builder(LI); | ||||||||||
|
||||||||||
Value *FirstActive = | ||||||||||
*llvm::find_if(DeinterleaveValues, [](Value *V) { return V != nullptr; }); | ||||||||||
VectorType *ResVTy = cast<VectorType>(FirstActive->getType()); | ||||||||||
auto FirstActiveItr = | ||||||||||
llvm::find_if(DeinterleaveValues, [](Value *V) { return V != nullptr; }); | ||||||||||
VectorType *ResVTy = cast<VectorType>((*FirstActiveItr)->getType()); | ||||||||||
|
||||||||||
const DataLayout &DL = LI->getDataLayout(); | ||||||||||
|
||||||||||
if (!isLegalInterleavedAccessType(ResVTy, Factor, LI->getAlign(), | ||||||||||
LI->getPointerAddressSpace(), DL)) | ||||||||||
return false; | ||||||||||
|
||||||||||
Value *Return; | ||||||||||
Type *PtrTy = LI->getPointerOperandType(); | ||||||||||
Type *XLenTy = Type::getIntNTy(LI->getContext(), Subtarget.getXLen()); | ||||||||||
|
||||||||||
// If the segment load is going to be performed segment at a time anyways | ||||||||||
// and there's only one element used, use a strided load instead. This | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. element -> field? |
||||||||||
// will be equally fast, and create less vector register pressure. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
if (!Subtarget.hasOptimizedSegmentLoadStore(Factor) && | ||||||||||
1 == llvm::count_if(DeinterleaveValues, | ||||||||||
[](Value *V) { return V != nullptr; })) { | ||||||||||
Comment on lines
+262
to
+263
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit
Suggested change
|
||||||||||
unsigned Idx = std::distance(DeinterleaveValues.begin(), FirstActiveItr); | ||||||||||
unsigned ScalarSizeInBytes = DL.getTypeStoreSize(ResVTy->getElementType()); | ||||||||||
Value *Stride = ConstantInt::get(XLenTy, Factor * ScalarSizeInBytes); | ||||||||||
Value *Offset = ConstantInt::get(XLenTy, Idx * ScalarSizeInBytes); | ||||||||||
Value *BasePtr = Builder.CreatePtrAdd(LI->getPointerOperand(), Offset); | ||||||||||
Value *Mask = Builder.getAllOnesMask(ResVTy->getElementCount()); | ||||||||||
Type *I32 = Type::getIntNTy(LI->getContext(), 32); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type::getInt32Ty? |
||||||||||
Value *VL = Builder.CreateElementCount(I32, ResVTy->getElementCount()); | ||||||||||
|
||||||||||
CallInst *CI = | ||||||||||
Builder.CreateIntrinsic(Intrinsic::experimental_vp_strided_load, | ||||||||||
{ResVTy, BasePtr->getType(), Stride->getType()}, | ||||||||||
{BasePtr, Stride, Mask, VL}); | ||||||||||
Align A = commonAlignment(LI->getAlign(), Idx * ScalarSizeInBytes); | ||||||||||
CI->addParamAttr(0, Attribute::getWithAlignment(CI->getContext(), A)); | ||||||||||
(*FirstActiveItr)->replaceAllUsesWith(CI); | ||||||||||
return true; | ||||||||||
} | ||||||||||
|
||||||||||
Value *Return; | ||||||||||
if (isa<FixedVectorType>(ResVTy)) { | ||||||||||
Value *VL = Builder.CreateElementCount(XLenTy, ResVTy->getElementCount()); | ||||||||||
Value *Mask = Builder.getAllOnesMask(ResVTy->getElementCount()); | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.