Re: let-bindings floating more easily, would a check for `exprIsOkForSpeculation scrut` in theory suffice to float out cases?
Yes; but instead we simply turn such cases into lets.
Simon
From: Sebastian Graf [mailto:sgraf1337@gmail.com]
Sent: 02 November 2017 08:33
To: Simon Peyton Jones <simonpj@microsoft.com>
Cc: ghc-devs <ghc-devs@haskell.org>
Subject: Re: When does GHC produce unlifted `let` bindings?
Thanks both of you, that makes sense.
Re: let-bindings floating more easily, would a check for `exprIsOkForSpeculation scrut` in theory suffice to float out cases?
On Mon, Oct 30, 2017 at 10:56 AM, Simon Peyton Jones <simonpj@microsoft.com> wrote:
See Note [CoreSyn let/app invariant] in CoreSyn.
Briefly, you can write
let x::Int# = e in …
if e is “ok-for-speculation”. See extensive comments in CoreUtils on what that means.
You could also use case, but let-bindings “float” more easily than cases, because they are not worried about preserving exception behaviour.
Simon
From: ghc-devs [mailto:ghc-devs-bounces@haskell.org] On Behalf Of Sebastian Graf
Sent: 29 October 2017 21:07
To: ghc-devs <ghc-devs@haskell.org>
Subject: When does GHC produce unlifted `let` bindings?
Hi folks,
I was debugging a Core-to-Core transform for TEST=spec-inline and was wondering (yet again) why GHC produces unlifted `let` bindings in Core like it seems supposed to be doing.
- Why doesn't this use `case` instead?
- Is there a semantic difference?
- Can `case` be used with unlifted types?
- And if not, why can `let`?
Unlifted `let` seems much close to `case` than to `let`. Some GHC passes seem to agree.
Cheers,
Sebastian