diff options
author | Jessica Paquette <jpaquette@apple.com> | 2021-03-24 23:45:36 -0700 |
---|---|---|
committer | Jessica Paquette <jpaquette@apple.com> | 2021-03-25 17:14:25 -0700 |
commit | 23f657c165da1b599d79de11980583968d8e6a91 (patch) | |
tree | a953c5fc1138d19b5e6388ae48bde5ff330364ca /llvm/lib/CodeGen/MachineVerifier.cpp | |
parent | 11bf268864afbe35ad317e6354c51440d5184911 (diff) | |
download | llvm-23f657c165da1b599d79de11980583968d8e6a91.zip llvm-23f657c165da1b599d79de11980583968d8e6a91.tar.gz llvm-23f657c165da1b599d79de11980583968d8e6a91.tar.bz2 |
[AArch64][GlobalISel] Emit bzero on Darwin
Darwin platforms for both AArch64 and X86 can provide optimized `bzero()`
routines. In this case, it may be preferable to use `bzero` in place of a
memset of 0.
This adds a G_BZERO generic opcode, similar to G_MEMSET et al. This opcode can
be generated by platforms which may want to use bzero.
To emit the G_BZERO, this adds a pre-legalize combine for AArch64. The
conditions for this are largely a port of the bzero case in
`AArch64SelectionDAGInfo::EmitTargetCodeForMemset`.
The only difference in comparison to the SelectionDAG code is that, when
compiling for minsize, this will fire for all memsets of 0. The original code
notes that it's not beneficial to do this for small memsets; however, using
bzero here will save a mov from wzr. For minsize, I think that it's preferable
to prioritise omitting the mov.
This also fixes a bug in the libcall legalization code which would delete
instructions which could not be legalized. It also adds a check to make sure
that we actually get a libcall name.
Code size improvements (Darwin):
- CTMark -Os: -0.0% geomean (-0.1% on pairlocalalign)
- CTMark -Oz: -0.2% geomean (-0.5% on bullet)
Differential Revision: https://reviews.llvm.org/D99358
Diffstat (limited to 'llvm/lib/CodeGen/MachineVerifier.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineVerifier.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp index af8b84e..9966600 100644 --- a/llvm/lib/CodeGen/MachineVerifier.cpp +++ b/llvm/lib/CodeGen/MachineVerifier.cpp @@ -1509,26 +1509,28 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) { break; } + case TargetOpcode::G_BZERO: case TargetOpcode::G_MEMSET: { ArrayRef<MachineMemOperand *> MMOs = MI->memoperands(); + std::string Name = Opc == TargetOpcode::G_MEMSET ? "memset" : "bzero"; if (MMOs.size() != 1) { - report("memset must have 1 memory operand", MI); + report(Twine(Name, " must have 1 memory operand"), MI); break; } if ((!MMOs[0]->isStore() || MMOs[0]->isLoad())) { - report("memset memory operand must be a store", MI); + report(Twine(Name, " memory operand must be a store"), MI); break; } LLT DstPtrTy = MRI->getType(MI->getOperand(0).getReg()); if (!DstPtrTy.isPointer()) { - report("memset operand must be a pointer", MI); + report(Twine(Name, " operand must be a pointer"), MI); break; } if (DstPtrTy.getAddressSpace() != MMOs[0]->getAddrSpace()) - report("inconsistent memset address space", MI); + report("inconsistent " + Twine(Name, " address space"), MI); break; } |