-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[RISCV] Add +optimized-nfN-segment-load-store #114414
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 |
---|---|---|
|
@@ -716,6 +716,28 @@ RISCVTTIImpl::getMaskedMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, | |
return getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, CostKind); | ||
} | ||
|
||
static bool hasOptimizedSegmentLoadStore(unsigned NF, | ||
const RISCVSubtarget *ST) { | ||
switch (NF) { | ||
case 2: | ||
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. Save some lines via using macros? 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. I considered it but remembered coming across some PRs where people were actively trying to remove uses of macros in LLVM, e.g. #105551 I'm not strongly opinionated on this, is there a general stance we should take here? 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.
Not found in https://llvm.org/docs/CodingStandards.html. I think it's OK not to use macros here, just a weak suggestion. |
||
return ST->hasOptimizedNF2SegmentLoadStore(); | ||
case 3: | ||
return ST->hasOptimizedNF3SegmentLoadStore(); | ||
case 4: | ||
return ST->hasOptimizedNF4SegmentLoadStore(); | ||
case 5: | ||
return ST->hasOptimizedNF5SegmentLoadStore(); | ||
case 6: | ||
return ST->hasOptimizedNF6SegmentLoadStore(); | ||
case 7: | ||
return ST->hasOptimizedNF7SegmentLoadStore(); | ||
case 8: | ||
return ST->hasOptimizedNF8SegmentLoadStore(); | ||
default: | ||
llvm_unreachable("Unexpected NF"); | ||
} | ||
} | ||
|
||
InstructionCost RISCVTTIImpl::getInterleavedMemoryOpCost( | ||
unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices, | ||
Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, | ||
|
@@ -737,9 +759,9 @@ InstructionCost RISCVTTIImpl::getInterleavedMemoryOpCost( | |
TLI->isLegalInterleavedAccessType(SubVecTy, Factor, Alignment, | ||
AddressSpace, DL)) { | ||
|
||
// Most available hardware today optimizes NF=2 as as one wide memory op | ||
// + Factor * LMUL shuffle ops. | ||
if (Factor == 2) { | ||
// Some processors optimize segment loads/stores as one wide memory op + | ||
// Factor * LMUL shuffle ops. | ||
if (hasOptimizedSegmentLoadStore(Factor, ST)) { | ||
InstructionCost Cost = | ||
getMemoryOpCost(Opcode, VTy, Alignment, AddressSpace, CostKind); | ||
MVT SubVecVT = getTLI()->getValueType(DL, SubVecTy).getSimpleVT(); | ||
|
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.
A random thought: There are 250 features for RISCV now, we may need to increase
MAX_SUBTARGET_FEATURES
soon.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.
Isn't the limit 5*64 or 320?
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.
Yes, but that won't last long, especially if we add some fusions (like XiangShan).