[Git][ghc/ghc][wip/andreask/reg-offset] Aarch ncg: Optimize immediate use for address calculations
Andreas Klebinger (@AndreasK)
gitlab at gitlab.haskell.org
Sat Jul 29 23:06:25 UTC 2023
Andreas Klebinger pushed to branch wip/andreask/reg-offset at Glasgow Haskell Compiler / GHC
Commits:
e16cd38b by Andreas Klebinger at 2023-07-30T01:00:27+02:00
Aarch ncg: Optimize immediate use for address calculations
When the offset doesn't fit into the immediate we now just reuse the
general getRegister' code path which is well optimized to compute the
offset into a register instead of a special case for CmmRegOff.
- - - - -
1 changed file:
- compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
Changes:
=====================================
compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
=====================================
@@ -711,18 +711,11 @@ getRegister' config plat expr
-> return (Fixed (cmmTypeFormat (cmmRegType reg))
(getRegisterReg plat reg)
nilOL)
- CmmRegOff reg off | isNbitEncodeable 12 (fromIntegral off) -> do
- getRegister' config plat $
- CmmMachOp (MO_Add width) [CmmReg reg, CmmLit (CmmInt (fromIntegral off) width)]
- where width = typeWidth (cmmRegType reg)
-
- CmmRegOff reg off -> do
- (off_r, _off_format, off_code) <- getSomeReg $ CmmLit (CmmInt (fromIntegral off) width)
- (reg, _format, code) <- getSomeReg $ CmmReg reg
- return $ Any (intFormat width) (\dst -> off_code `appOL` code `snocOL` ADD (OpReg width dst) (OpReg width reg) (OpReg width off_r))
- where width = typeWidth (cmmRegType reg)
-
-
+ CmmRegOff reg off ->
+ -- If we got here we will load the address into a register either way. So we might as well just expand
+ -- and re-use the existing code path to handle "reg + off".
+ let !width = cmmRegWidth reg
+ in getRegister' config plat (CmmMachOp (MO_Add width) [CmmReg reg, CmmLit (CmmInt (fromIntegral off) width)])
-- for MachOps, see GHC.Cmm.MachOp
-- For CmmMachOp, see GHC.Cmm.Expr
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e16cd38b3e10f1dbd93ed093827031dc5540d539
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e16cd38b3e10f1dbd93ed093827031dc5540d539
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230729/b5326b79/attachment-0001.html>
More information about the ghc-commits
mailing list