[Git][ghc/ghc][master] StgCmmPrim: remove an unnecessary instruction in doNewArrayOp

Marge Bot gitlab at gitlab.haskell.org
Sat Apr 20 03:38:14 UTC 2019



 Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
eb2a4df8 by Michal Terepeta at 2019-04-20T03:32:08Z
StgCmmPrim: remove an unnecessary instruction in doNewArrayOp

Previously we would generate a local variable pointing after the array
header and use it to initialize the array elements. But we already use
stores with offset, so it's easy to just add the header to those offsets
during compilation and avoid generating the local variable (which would
become a LEA instruction when using native codegen; LLVM already
optimizes it away).

Signed-off-by: Michal Terepeta <michal.terepeta at gmail.com>

- - - - -


1 changed file:

- compiler/codeGen/StgCmmPrim.hs


Changes:

=====================================
compiler/codeGen/StgCmmPrim.hs
=====================================
@@ -2143,11 +2143,8 @@ doNewArrayOp res_r rep info payload n init = do
     emit $ mkAssign arr base
 
     -- Initialise all elements of the array
-    p <- assignTemp $ cmmOffsetB dflags (CmmReg arr) (hdrSize dflags rep)
-    let initialization =
-            [ mkStore (cmmOffsetW dflags (CmmReg (CmmLocal p)) off) init
-            | off <- [0.. n - 1]
-            ]
+    let mkOff off = cmmOffsetW dflags (CmmReg arr) (hdrSizeW dflags rep + off)
+        initialization = [ mkStore (mkOff off) init | off <- [0.. n - 1] ]
     emit (catAGraphs initialization)
 
     emit $ mkAssign (CmmLocal res_r) (CmmReg arr)



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/eb2a4df84cd7d66bb27f8ccb08ef10d5c984e892

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/eb2a4df84cd7d66bb27f8ccb08ef10d5c984e892
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/20190419/05e786d2/attachment.html>


More information about the ghc-commits mailing list