Strictness in data declaration not matched in assembler?

Don Stewart dons at galois.com
Wed Oct 15 19:12:13 EDT 2008


twhitehead:
> Consider the following code
> 
> data Data = Data { unData :: !Int }
> 
> func :: Data -> Int
> func x = case unData x of
>            1 -> 2
>            _ -> 0
> 
> Compiling with GHC 6.8.2 gives the following stg code
> 
> Main.func =
>     \r [x_slg]
>         case x_slg of tpl_slx {
>           Main.Data ipv_slj ->
>               case ipv_slj of wild_sly {
>                 GHC.Base.I# ds_slm ->
>                     case ds_slm of ds1_slz {
>                       __DEFAULT -> Main.lvl1;
>                       1 -> Main.lvl;
>                     };
>               };
>         };


Note that using -funbox-strict-fields helps,

    A.func :: A.Data -> Int
    A.func =
      \ (x_afx :: A.Data) ->
        case x_afx of tpl_B2 { A.Data rb_B4 ->
            case rb_B4 of ds_Xg7 {
                 __DEFAULT -> A.lvl1
                 1         -> A.lvl }
        }

No I#.

I'd expect if 'func' was inlined, for the return to be unboxed as well.

-- Don


More information about the Glasgow-haskell-users mailing list