Unexpected boxing in generated code
Simon PeytonJones
simonpj at microsoft.com
Tue Jul 10 07:23:05 EDT 2007
Very curious. It does indeed look as though the strictness analyser is confused; but it should certainly not be confused by mutual recursion. I'll definitely look into it. But don't hold your breath  it's a very busy fortnight.
Simon
 Original Message
 From: glasgowhaskellusersbounces at haskell.org [mailto:glasgowhaskellusersbounces at haskell.org] On
 Behalf Of Neil Mitchell
 Sent: 09 July 2007 23:14
 To: glasgowhaskellusers at haskell.org
 Subject: Unexpected boxing in generated code

 Hi,

 I've got an inner loop that I think I can see is strict in the Int
 argument being passed around, but that GHC 6.6.1 isn't unboxing. In
 the following example both functions take a GHC.Base.Int, which I
 think should be an Int#.

 Rec {
 f60_rS5 :: GHC.Prim.State# GHC.Prim.RealWorld > GHC.Base.Int > GHC.Base.Int
 [GlobalId]
 [Arity 2
 NoCafRefs
 Str: DmdType LL]
 f60_rS5 =
 \ (v1_aWH :: GHC.Prim.State# GHC.Prim.RealWorld) (v2_aWI :: GHC.Base.Int) >
 case $wccall_r2kv v1_aWH of wild_X2j { (# ds_d1V4, ds1_d1V3 #) >
 case ds1_d1V3 of wild1_X2L {
 __DEFAULT > f60_rS5 ds_d1V4 v2_aWI;
 (1) > v2_aWI;
 10 > f561_r2kx ds_d1V4 v2_aWI
 }
 }
 f561_r2kx :: GHC.Prim.State# GHC.Prim.RealWorld > GHC.Base.Int > GHC.Base.Int
 [GlobalId]
 [Arity 2
 NoCafRefs
 Str: DmdType LL]
 f561_r2kx =
 \ (v1_aWm :: GHC.Prim.State# GHC.Prim.RealWorld) (v2_aWn :: GHC.Base.Int) >
 case $wccall_r2kv v1_aWm of wild_X2j { (# ds_d1V4, ds1_d1V3 #) >
 case ds1_d1V3 of wild1_X2P {
 __DEFAULT >
 case v2_aWn of wild2_a2du { GHC.Base.I# x_a2dw >
 case wild1_X2P of wild3_X35 {
 __DEFAULT > f60_rS5 ds_d1V4 (GHC.Base.I# (GHC.Prim.+# x_a2dw 1));
 10 > f561_r2kx ds_d1V4 (GHC.Base.I# (GHC.Prim.+# x_a2dw 1))
 }
 };
 (1) > v2_aWn
 }
 }
 end Rec }

 This code comes from a line counting program, I have attached the
 entire source. My character counting program does infer the correct
 strictness, although that is based on a single selfrecursive
 function. The largest obvious difference is that the strictness
 depends on the two functions which call each other  does this impeed
 GHC's strictness analysis?

 Thanks

 Neil
More information about the Glasgowhaskellusers
mailing list