[GHC] #2163: GHC makes thunks for Integers we are strict in

Ian Lynagh igloo at earth.li
Wed Mar 19 13:31:08 EDT 2008

On Tue, Mar 18, 2008 at 04:12:35PM -0000, GHC wrote:
> > W.f =
> >   \ (x_a5h :: GHC.Num.Integer) ->
> >     let {
> >       x'_sa7 [ALWAYS Just S] :: GHC.Num.Integer
> >       [Str: DmdType]
> >       x'_sa7 = GHC.Num.plusInteger x_a5h W.lvl } in
> >     GHC.Num.timesInteger x'_sa7 x'_sa7
>  `let` can be strict in Core - it doesn't always indicate a thunk.

Aha! I knew that let was strict for types like Int#, but didn't realise
that it could be for "normal" types too.

What is it in the above let that shows that it will be evaluated
strictly? The "Just S"?

Also, what is the advantage to having strictly evaluated let's, both for
unboxed and normal types? Presumably it helps with some optimisation -
perhaps let-bound things might be inlined, whereas case'd things aren't,
which reduces the number of cases the optimiser needs to consider, or

>  (don't worry, this often catches me out too.  Perhaps a strict let
>  should be indicated more explicitly in `-ddump-simpl`).

I'd certainly find it useful if it was clearer.


More information about the Glasgow-haskell-users mailing list