aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Nested/Mixed/Shape/Internal.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data/Array/Nested/Mixed/Shape/Internal.hs')
-rw-r--r--src/Data/Array/Nested/Mixed/Shape/Internal.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Data/Array/Nested/Mixed/Shape/Internal.hs b/src/Data/Array/Nested/Mixed/Shape/Internal.hs
index 9997b0f..2a86ac1 100644
--- a/src/Data/Array/Nested/Mixed/Shape/Internal.hs
+++ b/src/Data/Array/Nested/Mixed/Shape/Internal.hs
@@ -20,9 +20,11 @@ ixFromLinearStub fname' ishty ixty zshC consshC ixz ixcons shtolist = do
locals <- [d|
-- Unfold first iteration of fromLin to do the range check.
- -- Don't inline because if this is inlined, GHC seems to stop sharing
- -- 'suffixes' over multiple calls, which breaks performance in sh*Enum.
- {-# NOINLINE fromLin0 #-}
+ -- Don't inline this function at first to allow GHC to inline the outer
+ -- function and realise that 'suffixes' is shared. But then later inline it
+ -- anyway, to avoid the function call. Removing the pragma makes GHC
+ -- somehow unable to recognise that 'suffixes' can be shared in a loop.
+ {-# NOINLINE [0] fromLin0 #-}
fromLin0 :: Num i => $ishty sh -> [Int] -> Int -> $ixty sh i
fromLin0 sh suffixes i =
if i < 0 then outrange sh i else