Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,25 @@ bool LoongArchTTIImpl::shouldExpandReduction(const IntrinsicInst *II) const {
}
}

// TODO: Implement more hooks to provide TTI machinery for LoongArch.
LoongArchTTIImpl::TTI::MemCmpExpansionOptions
LoongArchTTIImpl::enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IsZeroCmp is not used currently?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It is not been used for now. Whether it is ZeroCmp or not, enable memcmp expansion is beneficial.

TTI::MemCmpExpansionOptions Options;

if (!ST->hasUAL())
return Options;

Options.MaxNumLoads = TLI->getMaxExpandSizeMemcmp(OptSize);
Options.NumLoadsPerBlock = Options.MaxNumLoads;
Options.AllowOverlappingLoads = true;

// TODO: Support for vectors.
if (ST->is64Bit()) {
Options.LoadSizes = {8, 4, 2, 1};
Options.AllowedTailExpansions = {3, 5, 6};
} else {
Options.LoadSizes = {4, 2, 1};
Options.AllowedTailExpansions = {3};
}

return Options;
}
3 changes: 2 additions & 1 deletion llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class LoongArchTTIImpl : public BasicTTIImplBase<LoongArchTTIImpl> {

bool shouldExpandReduction(const IntrinsicInst *II) const override;

// TODO: Implement more hooks to provide TTI machinery for LoongArch.
TTI::MemCmpExpansionOptions
enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const override;
};

} // end namespace llvm
Expand Down
Loading