How to disable the simple optimizer
Simon Peyton Jones
simon.peytonjones at gmail.com
Fri Jan 26 13:10:53 UTC 2024
Hi Facundo
Currently there is no way to disable the simple optimiser, but it would be
easy to add a flag to do so.
I'm not sure if that is really what you want -- you'll be left with a
program with a lot of "junk" like (let x = y in ...). But maybe LH
doesn't mind the junk!
If you decide that is what you want, I'm sure we (or you) can add a flag to
control it. The relevant code is in GHC.HsToCore, below
Before you go much further, do open a ticket.
Simon
I think this the code you want to disable with a flag:
; let simpl_opts = initSimpleOpts dflags
; let (ds_binds, ds_rules_for_imps, occ_anald_binds)
= simpleOptPgm simpl_opts mod final_pgm rules_for_imps
-- The simpleOptPgm gets rid of type
-- bindings plus any stupid dead code
; putDumpFileMaybe logger Opt_D_dump_occur_anal "Occurrence
analysis"
FormatCore (pprCoreBindings occ_anald_binds $$ pprRules
ds_rules_for_imps )
; endPassHscEnvIO hsc_env name_ppr_ctx CoreDesugarOpt ds_binds
ds_rules_for_imps
On Fri, 26 Jan 2024 at 12:29, Facundo DomÃnguez <facundo.dominguez at tweag.io>
wrote:
> Dear devs,
>
> I noticed that GHC sometimes inlines bindings during desugaring, e.g
>
> foo = z
> where
> z = z1 + z2
> z1 = 42
> z2 = 1
>
> is desugared to
>
> foo = 42 + 1
>
> This inlining is problematic when using a plugin like Liquid Haskell,
> which wants to analyse in Core the local bindings provided by the
> user.
>
> Until ghc-9.6 LH didn't experience the inlining when using the GHC
> API. And this is despite the fact that using ghc from the command
> line would seem to always inline during desugaring, even when using
> -O0.
>
> When using ghc-9.8.1 though, even the output of the GHC API started
> having the bindings inlined. Some debugging with -ddump-ds and
> -ddump-ds-preopt shows that inlining must be happening in the simple
> optimizer.
>
> Is there anything one could do to disable the optimizations?
>
> Thanks in advance,
> Facundo
>
> --
> All views and opinions expressed in this email message are the
> personal opinions of the author and do not represent those of the
> organization or its customers.
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20240126/9c99d6a4/attachment.html>
More information about the ghc-devs
mailing list