[llvm] [BOLT][AArch64] Enabling Inlining for Memcpy for AArch64 in BOLT (PR #154929)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 27 06:52:21 PDT 2025
================
@@ -2597,6 +2597,132 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
getInstructionSize(const MCInst &Inst) const override {
return 4;
}
+
+ InstructionListType createInlineMemcpy(bool ReturnEnd) const override {
+ // Fallback
+ return createInlineMemcpy(ReturnEnd, std::nullopt);
+ }
+
+ std::optional<uint64_t>
+ extractMoveImmediate(const MCInst &Inst, MCPhysReg TargetReg) const override {
+ if (Inst.getOpcode() == AArch64::MOVZXi && Inst.getNumOperands() >= 3) {
+ if (Inst.getOperand(0).isReg() &&
+ Inst.getOperand(0).getReg() == TargetReg &&
+ Inst.getOperand(1).isImm() && Inst.getOperand(2).isImm() &&
+ Inst.getOperand(2).getImm() == 0) {
+ return Inst.getOperand(1).getImm();
+ }
+ }
+ return std::nullopt;
+ }
+
+ InstructionListType
+ createInlineMemcpy(bool ReturnEnd,
+ std::optional<uint64_t> KnownSize) const override {
+ InstructionListType Code;
+ if (ReturnEnd) {
+ if (KnownSize.has_value() && (*KnownSize >> 12) == 0) {
+ // Use immediate if size is known and fits in 12-bit immediate (0-4095)
+ Code.emplace_back(MCInstBuilder(AArch64::ADDXri)
----------------
yafet-a wrote:
No I wasn't but now I've simplified this in the latest commit to remove the condition. #Since it's always executed since all inlined sizes, 1-64, fit in the 12-bit immediate. Test covered in the _memcpy8 case.
https://github.com/llvm/llvm-project/pull/154929
More information about the llvm-commits
mailing list