diff options
author | Artem Pyanykh <artem.pyanykh@gmail.com> | 2019-04-11 14:20:03 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-04-14 01:26:35 -0400 |
commit | edcef7b384ca5af6e67d58c39779d03f80768538 (patch) | |
tree | 0a873348e5fc80f17cabdc0f5b6dddf15b70d07d /compiler/nativeGen/X86/CodeGen.hs | |
parent | 6febc444c0abea6c033174aa0e813c950b9b2877 (diff) | |
download | haskell-edcef7b384ca5af6e67d58c39779d03f80768538.tar.gz |
codegen: unroll memcpy calls for small bytearrays
Diffstat (limited to 'compiler/nativeGen/X86/CodeGen.hs')
-rw-r--r-- | compiler/nativeGen/X86/CodeGen.hs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/nativeGen/X86/CodeGen.hs b/compiler/nativeGen/X86/CodeGen.hs index 70df468857..b46ef6a935 100644 --- a/compiler/nativeGen/X86/CodeGen.hs +++ b/compiler/nativeGen/X86/CodeGen.hs @@ -1767,12 +1767,11 @@ genCCall -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --- Unroll memcpy calls if the source and destination pointers are at --- least DWORD aligned and the number of bytes to copy isn't too +-- Unroll memcpy calls if the number of bytes to copy isn't too -- large. Otherwise, call C's memcpy. -genCCall dflags is32Bit (PrimTarget (MO_Memcpy align)) _ +genCCall dflags _ (PrimTarget (MO_Memcpy align)) _ [dst, src, CmmLit (CmmInt n _)] _ - | fromInteger insns <= maxInlineMemcpyInsns dflags && align .&. 3 == 0 = do + | fromInteger insns <= maxInlineMemcpyInsns dflags = do code_dst <- getAnyReg dst dst_r <- getNewRegNat format code_src <- getAnyReg src @@ -1785,7 +1784,9 @@ genCCall dflags is32Bit (PrimTarget (MO_Memcpy align)) _ -- instructions per move. insns = 2 * ((n + sizeBytes - 1) `div` sizeBytes) - format = if align .&. 4 /= 0 then II32 else (archWordFormat is32Bit) + maxAlignment = wordAlignment dflags -- only machine word wide MOVs are supported + effectiveAlignment = min (alignmentOf align) maxAlignment + format = intFormat . widthFromBytes $ alignmentBytes effectiveAlignment -- The size of each move, in bytes. sizeBytes :: Integer |