diff options
author | Michal Terepeta <michal.terepeta@gmail.com> | 2019-04-14 21:21:17 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-04-19 23:32:08 -0400 |
commit | eb2a4df84cd7d66bb27f8ccb08ef10d5c984e892 (patch) | |
tree | fc511d4cc8df9fe3c7d66944a62a9dd380ef264d /compiler/codeGen | |
parent | fdfd97310128d82ac5316d357f0422c9939c1edc (diff) | |
download | haskell-eb2a4df84cd7d66bb27f8ccb08ef10d5c984e892.tar.gz |
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@gmail.com>
Diffstat (limited to 'compiler/codeGen')
-rw-r--r-- | compiler/codeGen/StgCmmPrim.hs | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/compiler/codeGen/StgCmmPrim.hs b/compiler/codeGen/StgCmmPrim.hs index e5aacd1f1b..0a667560f7 100644 --- a/compiler/codeGen/StgCmmPrim.hs +++ b/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) |