Unexpected boxing in generated code

Neil Mitchell ndmitchell at gmail.com
Mon Jul 9 18:13:34 EDT 2007


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 self-recursive
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 4.hs
Type: application/octet-stream
Size: 11869 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20070709/6060e02a/4-0001.obj


More information about the Glasgow-haskell-users mailing list