summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÖmer Sinan Ağacan <omeragacan@gmail.com>2019-03-22 10:06:37 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-03-27 07:20:10 -0400
commit5730f86331df4aa9b3d7b5ab59b1ebeafceaeadb (patch)
treecd5cf7266a7885e95f72f28c7cb6f033440e8d3d
parent3dec527a840a8165c33579bca09740ca9cf1f4de (diff)
downloadhaskell-5730f86331df4aa9b3d7b5ab59b1ebeafceaeadb.tar.gz
Minor refactoring in copy array primops:
- `emitCopySmallArray` now checks size before generating code and doesn't generate any code when size is 0. `emitCopyArray` already does this so this makes small/large array cases the same in argument checking. - In both `emitCopySmallArray` and `emitCopyArray` read the `dflags` after checking the argument.
-rw-r--r--compiler/codeGen/StgCmmPrim.hs32
1 files changed, 17 insertions, 15 deletions
diff --git a/compiler/codeGen/StgCmmPrim.hs b/compiler/codeGen/StgCmmPrim.hs
index a6f3395425..714e544f8f 100644
--- a/compiler/codeGen/StgCmmPrim.hs
+++ b/compiler/codeGen/StgCmmPrim.hs
@@ -2174,9 +2174,10 @@ emitCopyArray :: (CmmExpr -> CmmExpr -> CmmExpr -> CmmExpr -> ByteOff
-> CmmExpr -- ^ offset in destination array
-> WordOff -- ^ number of elements to copy
-> FCode ()
-emitCopyArray copy src0 src_off dst0 dst_off0 n = do
- dflags <- getDynFlags
+emitCopyArray copy src0 src_off dst0 dst_off0 n =
when (n /= 0) $ do
+ dflags <- getDynFlags
+
-- Passed as arguments (be careful)
src <- assignTempE src0
dst <- assignTempE dst0
@@ -2236,23 +2237,24 @@ emitCopySmallArray :: (CmmExpr -> CmmExpr -> CmmExpr -> CmmExpr -> ByteOff
-> CmmExpr -- ^ offset in destination array
-> WordOff -- ^ number of elements to copy
-> FCode ()
-emitCopySmallArray copy src0 src_off dst0 dst_off n = do
- dflags <- getDynFlags
+emitCopySmallArray copy src0 src_off dst0 dst_off n =
+ when (n /= 0) $ do
+ dflags <- getDynFlags
- -- Passed as arguments (be careful)
- src <- assignTempE src0
- dst <- assignTempE dst0
+ -- Passed as arguments (be careful)
+ src <- assignTempE src0
+ dst <- assignTempE dst0
- -- Set the dirty bit in the header.
- emit (setInfo dst (CmmLit (CmmLabel mkSMAP_DIRTY_infoLabel)))
+ -- Set the dirty bit in the header.
+ emit (setInfo dst (CmmLit (CmmLabel mkSMAP_DIRTY_infoLabel)))
- dst_p <- assignTempE $ cmmOffsetExprW dflags
- (cmmOffsetB dflags dst (smallArrPtrsHdrSize dflags)) dst_off
- src_p <- assignTempE $ cmmOffsetExprW dflags
- (cmmOffsetB dflags src (smallArrPtrsHdrSize dflags)) src_off
- let bytes = wordsToBytes dflags n
+ dst_p <- assignTempE $ cmmOffsetExprW dflags
+ (cmmOffsetB dflags dst (smallArrPtrsHdrSize dflags)) dst_off
+ src_p <- assignTempE $ cmmOffsetExprW dflags
+ (cmmOffsetB dflags src (smallArrPtrsHdrSize dflags)) src_off
+ let bytes = wordsToBytes dflags n
- copy src dst dst_p src_p bytes
+ copy src dst dst_p src_p bytes
-- | Takes an info table label, a register to return the newly
-- allocated array in, a source array, an offset in the source array,