[llvm] [AArch64] Optimise materialisation of large stack offset calculations (PR #201856)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 10 02:13:21 PDT 2026
================
@@ -7252,8 +7252,26 @@ int llvm::isAArch64FrameOffsetLegal(const MachineInstr &MI,
if (MinOff <= NewOffset && NewOffset <= MaxOff)
Offset = Remainder;
else {
- NewOffset = NewOffset < 0 ? MinOff : MaxOff;
- Offset = Offset - (NewOffset * Scale);
+ // Try to minimise the number of instructions required to materialise the
+ // offset calculation. Specifically, for fixed offsets, if masking out the
+ // low 12 bits leaves a legal add immediate, we can realise the offset
+ // calculation with a single add instruction. Whenever this is possible,
+ // prefer this split.
+ const TargetLowering *TLI = MI.getMF()->getSubtarget().getTargetLowering();
----------------
arsenm wrote:
```suggestion
const AArch64TargetLowering *TLI = MI.getMF()->getSubtarget<AArch64Subtarget>().getTargetLowering();
```
https://github.com/llvm/llvm-project/pull/201856
More information about the llvm-commits
mailing list