11{-# LANGUAGE BangPatterns #-}
2+ {-# LANGUAGE CPP #-}
23{-# LANGUAGE ScopedTypeVariables #-}
34{-# LANGUAGE TypeApplications #-}
45{- |
@@ -27,12 +28,23 @@ tests = testGroup "allocations"
2728 [ testCase " IO"
2829 $ checkAllocations (linear 8 )
2930 $ whnfIO (VU. traverse (\ _ -> getAllocationCounter) vector)
31+
32+ #if MIN_VERSION_base(4,17,0)
33+ -- GHC<9.4 doesn't optimize well.
3034 , testCase " ST"
3135 $ checkAllocations (linear 8 )
3236 $ (\ v -> runST $ VU. traverse (pureST . fromIntegral ) v) `whnf` vector
37+ #endif
38+
39+ #if MIN_VERSION_base(4,15,0)
40+ -- GHC<9.0 doesn't optimize this well. And there's no appetite
41+ -- for finding out why. Thus it's disabled for them. We'll still
42+ -- catch regression going forward.
3343 , testCase " Identity"
3444 $ checkAllocations (linear 8 )
3545 $ VU. traverse (\ n -> Identity (10 * n)) `whnf` vector
46+ #endif
47+
3648 -- NOTE: Naive traversal is lazy and allocated 2 words per element
3749 --
3850 -- , testCase "Const Sum"
@@ -43,9 +55,14 @@ tests = testGroup "allocations"
4355 [ testCase " IO"
4456 $ checkAllocations (linear 8 )
4557 $ whnfIO (VU. replicateM size getAllocationCounter)
58+
59+ #if MIN_VERSION_base(4,17,0)
60+ -- GHC<9.4 doesn't optimize well.
4661 , testCase " ST"
4762 $ checkAllocations (linear 8 )
4863 $ (\ sz -> runST $ VU. generateM sz pureST) `whnf` size
64+ #endif
65+
4966 -- , testCase "Identity"
5067 -- $ checkAllocations (linear 8)
5168 -- $ (\sz -> VU.generateM sz (\n -> Identity (fromIntegral n :: Int64))) `whnf` size
0 commit comments