<html><head><meta http-equiv="content-type" content="text/html; charset=us-ascii"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">Excellent!<div><br></div><div>I did a little experiment for myself, first this program, compiled at -O3 without the explicit command line option, using </div><div><br></div><div><div><i>Mercury Compiler, version 22.01.6, on aarch64-apple-darwin22.5.0</i></div><div><i>Copyright (C) 1993-2012 The University of Melbourne</i></div><div><i>Copyright (C) 2013-2023 The Mercury team</i></div><div><i>Usage: mmc [<options>] <arguments></i></div><div><i>Use `mmc --help' for more information.</i></div></div><div><br></div><div>The code:</div><div><br></div><div><div>main(!IO) :-</div><div><br></div><div> RESULT = 22.0 / 7.0,</div><div> io.format("Mercury demands focus! %f\n", [f(RESULT)], !IO).</div><div><br></div><div>This yields this C code:</div><div><div>void MR_CALL</div><div>main_2_p_0(void)</div><div>{</div><div> {</div><div> MR_Float RESULT_4;</div><div><b> MR_Float Var_7 = (MR_Float) 22.000000000000000;</b></div><div><b> MR_Float Var_8 = (MR_Float) 7.0000000000000000;</b></div><div> MR_String Var_15;</div><div> MR_String Var_17;</div><div> MR_Word Var_23;</div><div> MR_Word Var_24;</div><div> MR_String Var_25;</div><div><br></div><div><b> RESULT_4 = mercury__float__f_slash_2_f_0(Var_7, Var_8);</b></div></div><div><br></div><div>So I see that yes, it is still performing the evaluation at runtime, but with the --optimize-constant-propogation option:</div><div><br></div><div><div>void MR_CALL</div><div>main_2_p_0(void)</div><div>{</div><div> {</div><div><b> MR_Float RESULT_4 = (MR_Float) 3.1428571428571428;</b></div></div><div><br></div><div>So, thank you Zoltan.</div><div><br></div><div><br></div><div><br><blockquote type="cite"><div>On 18 Aug 2023, at 10:48, Zoltan Somogyi <zoltan.somogyi@runbox.com> wrote:</div><br class="Apple-interchange-newline"><div><div><br>On 2023-08-18 11:37 +02:00 CEST, "Julien Fischer" <jfischer@opturion.com> wrote:<br><blockquote type="cite">At -O3 and above the Mercury compiler will (generally) evaluate a<br>variety of operations (see compiler/const_prop.m for details).<br>Float division is included in those operations<br></blockquote><br>Actually, constant propagation is not enabled automatically at any<br>optimization level; you have to enable manually, with --optimize-constant-propagation.<br>What is enabled at -O3 is *constraint* propagation, which I also<br>misread as *constant* propagation at first :-(<br><br>I will add constant propagation to -O3.<br><br>Zoltan.<br>_______________________________________________<br>users mailing list<br>users@lists.mercurylang.org<br>https://lists.mercurylang.org/listinfo/users<br></div></div></blockquote></div><br></div></body></html>