<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi,</p>
<p>Indeed the optimisation level is directly queried in a few places
(e.g. grep "optLevel" and "opt_level"). Especially in Core opt
pipeline getCoreToDo returns:</p>
<p> core_todo =<br>
if opt_level == 0 then<br>
[ static_ptrs_float_outwards,<br>
CoreDoSimplify max_iter<br>
(base_mode { sm_phase = FinalPhase<br>
, sm_names = ["Non-opt simplification"] })<br>
, add_caller_ccs<br>
]<br>
<br>
else {- opt_level >= 1 -} [...]<br>
</p>
<p>Somewhat relevant issue:
<a class="moz-txt-link-freetext" href="https://gitlab.haskell.org/ghc/ghc/-/issues/17844">https://gitlab.haskell.org/ghc/ghc/-/issues/17844</a><br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 11/10/2021 06:08, Erdi, Gergo via
ghc-devs wrote:<br>
</div>
<blockquote type="cite"
cite="mid:HK0PR03MB486798660BFBD07608B36EB3E9B59@HK0PR03MB4867.apcprd03.prod.outlook.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style>@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}@font-face
{font-family:"Lucida Console";
panose-1:2 11 6 9 4 5 4 2 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
mso-add-space:auto;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst
{mso-style-priority:34;
mso-style-type:export-only;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
mso-add-space:auto;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle
{mso-style-priority:34;
mso-style-type:export-only;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
mso-add-space:auto;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast
{mso-style-priority:34;
mso-style-type:export-only;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
mso-add-space:auto;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}span.EmailStyle22
{mso-style-type:personal-compose;
font-family:"Arial",sans-serif;
color:windowtext;
font-weight:normal;
font-style:normal;}.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}div.WordSection1
{page:WordSection1;}ol
{margin-bottom:0in;}ul
{margin-bottom:0in;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<p class="msipheader7557e74b" style="margin:0" align="Left"><span
style="font-size:9.0pt;font-family:Arial;color:#317100">PUBLIC</span></p>
<br>
<div class="WordSection1">
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">What
is set by -O* that is not included in optLevelFlags?<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">I
would have thought that setting all the flags implied by,
e.g., -O1, would be the same as setting -O1 itself. But this
is not the case! Here are all the flags for O1 from
optLevelFlags:<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_DoLambdaEtaExpansion<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_DoEtaReduction<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_LlvmTBAA<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_CallArity<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_Exitification<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_CaseMerge<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_CaseFolding<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_CmmElimCommonBlocks<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_CmmSink<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_CmmStaticPred<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_CSE<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_StgCSE<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_EnableRewriteRules<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_FloatIn<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_FullLaziness<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_IgnoreAsserts<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_Loopification<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_CfgBlocklayout<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_Specialise<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_CrossModuleSpecialise<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_InlineGenerics<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_Strictness<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_UnboxSmallStrictFields<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_CprAnal<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_WorkerWrapper<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_SolveConstantDicts<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_NumConstantFolding<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">And
here are the ones that are set by O0 (the default) but not
by O1:<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_IgnoreInterfacePragmas<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Opt_OmitInterfacePragmas<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">So
I expected that the following two invocations of GHC would
be equivalent:<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<ol style="margin-top:0in" type="1" start="1">
<li class="MsoListParagraphCxSpFirst"
style="margin-left:0in;mso-add-space:auto;mso-list:l1 level1
lfo4">
<span style="font-family:"Lucida Console"">ghc -O1</span><span
style="font-size:10.0pt;font-family:"Arial",sans-serif"><o:p></o:p></span></li>
<li class="MsoListParagraphCxSpLast"
style="margin-left:0in;mso-add-space:auto;mso-list:l1 level1
lfo4">
<span style="font-family:"Lucida Console"">ghc
-fdo-lambda-eta-expansion -fdo-eta-reduction -fllvm-tbaa
-fcall-arity -fexitification -fcase-merge -fcase-folding
-fcmm-elim-common-blocks -fcmm-sink -fcmm-static-pred
-fcse -fstg-cse -fenable-rewrite-rules -ffloat-in
-ffull-laziness -fignore-asserts -floopification
-fblock-layout-cfg -fspecialise -fcross-module-specialise
-finline-generics -fstrictness -funbox-small-strict-fields
-fcpr-anal -fworker-wrapper -fsolve-constant-dicts
-fnum-constant-folding -fno-ignore-interface-pragmas
-fno-omit-interface-pragmas</span><span
style="font-size:10.0pt;font-family:"Arial",sans-serif"><o:p></o:p></span></li>
</ol>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">However,
just by observing the output of -dshow-passes, I can see
that while -O1 applies all these optimizations, the second
version does NOT, even though I have turned on each and
every one of them one by one. <o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif">Looking
at compiler/GHC/Driver/Session.hs, it is not at all clear
that -O* should do more than just setting the flags from
optLevelFlags. What other flags are implied by -O*?<o:p></o:p></span></p>
</div>
<br clear="all">
This email and any attachments are confidential and may also be
privileged. If you are not the intended recipient, please delete
all copies and notify the sender immediately. You may wish to
refer to the incorporation details of Standard Chartered PLC,
Standard Chartered Bank and their subsidiaries at https:
//www.sc.com/en/our-locations<br>
<br>
Where you have a Financial Markets relationship with Standard
Chartered PLC, Standard Chartered Bank and their subsidiaries (the
"Group"), information on the regulatory standards we adhere to and
how it may affect you can be found in our Regulatory Compliance
Statement at https: //www.sc.com/rcs/ and Regulatory Compliance
Disclosures at http: //www.sc.com/rcs/fm<br>
<br>
Insofar as this communication is not sent by the Global Research
team and contains any market commentary, the market commentary has
been prepared by the sales and/or trading desk of Standard
Chartered Bank or its affiliate. It is not and does not constitute
research material, independent research, recommendation or
financial advice. Any market commentary is for information purpose
only and shall not be relied on for any other purpose and is
subject to the relevant disclaimers available at https:
//www.sc.com/en/regulatory-disclosures/#market-disclaimer.<br>
<br>
Insofar as this communication is sent by the Global Research team
and contains any research materials prepared by members of the
team, the research material is for information purpose only and
shall not be relied on for any other purpose, and is subject to
the relevant disclaimers available at https:
//research.sc.com/research/api/application/static/terms-and-conditions.
<br>
<br>
Insofar as this e-mail contains the term sheet for a proposed
transaction, by responding affirmatively to this e-mail, you agree
that you have understood the terms and conditions in the attached
term sheet and evaluated the merits and risks of the transaction.
We may at times also request you to sign the term sheet to
acknowledge the same.<br>
<br>
Please visit https:
//www.sc.com/en/regulatory-disclosures/dodd-frank/ for important
information with respect to derivative products.<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
ghc-devs mailing list
<a class="moz-txt-link-abbreviated" href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a>
</pre>
</blockquote>
</body>
</html>