<div dir="ltr">No, I think that's ok as-is. We still allow 'fast' in IR text as a shortcut meaning all of the other bits are set. It's just encoded differently in binary form.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 9, 2018 at 11:07 AM, Andrew Kelley via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Does the language reference need to be updated?<br><br><a href="http://llvm.org/docs/LangRef.html#fast-math-flags" target="_blank">http://llvm.org/docs/LangRef.<wbr>html#fast-math-flags</a><br><br></div>It still mentions "fast"<br><div><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Thu, Feb 8, 2018 at 8:34 PM, Quentin Colombet via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div style="word-wrap:break-word;line-break:after-white-space">Hi,<div><br></div><div>TL;DR</div><div>r317488 changed the way fast math flags are laid out in the bitcode and anyone compiling a pre-llvm-6.0 bitcode with llvm-6.0 will lose all the optimizations guarded by isFast and a pre-llvm-6.0 compiler compiling a llvm-6.0 bitcode will potentially generate incorrect code w.r.t. fast math expectations.</div><div><br></div><div>Should we bump the bitcode version because of that and have the autoupgrader properly rewrite the fast-math to preserve that semantic?</div><div>(I believe we should!)</div><div><br></div><div><br></div><div>* Context *</div><div><br></div><div>With <a href="https://reviews.llvm.org/D39304" target="_blank">https://reviews.llvm.org/<wbr>D39304</a> / r317488 we got rid of the umbrella UnsafeMath flag and introduced 3 more flags that better represent the different things that happen under fast-math.</div><div><br></div><div>From a bitcode perspective, this change looks like this:</div><div>Before r317488 we had 6 bits that respectively represented:</div><div><br></div><div>UnsafeMath</div><div>nnan</div><div>ninf</div><div>nsz</div><div>arcp</div><div>contract</div><div>*unset*</div><div><br></div><div>(The order may not match what is exactly in the bitcode.)</div><div><br></div><div><div>After r317488 we had 7 bits that respectively represented:</div></div><div><div>reassoc (-UnsafeMath- is gone)</div><div>nnan</div><div>ninf</div><div>nsz</div><div>arcp</div><div>contract</div></div><div>*afn* (new bit)</div><div><br></div><div>Before r317488, fast-math was true if UnsafeMath was true (this should also imply all the other flags are sets). After r317488, fast-math is true if all the bits are set, in particular the afn, new one, too.</div><div><br></div><div><br></div><div>* Problem *</div><div><br></div><div>Given we currently have no way to check if a bitcode file has been generated pre-r317488 or post-r317488 that means that:</div><div>1. a post-r317488 compiler is going to skip any optimization guarded by isFast for all pre-r317488 bitcode file (remember the afn bit is not set here)</div><div>2. a pre-r317488 compiler is going to run any optimization guarded by unsafeAlgebra for any post-r317488 bitcode file that has the reassoc bit (remember we repurposed UnsafeMath)</div><div><br></div><div>Scenario #2 might be unlikely but we’re potentially breaking the semantic of the program. It is particularly dangerous because there is nothing that is going to tell us that we are in this situation “downgrade" situation.</div><div>#1 means that any code that uses unsafeMath is going to get a performance hit.</div><div><br></div><div>In other words, one scenario implies generating wrong code and the other, runtime performance regressions.</div><div><br></div><div><br></div><div>* Feedback Needed *</div><div><br></div><div>I believe this change is big enough that it would be worth bumping the bitcode version so that the upgrader can do the right thing *before* we release it to the public with LLVM-6.0.</div><div><br></div><div>That being said, I don’t know what are the implications of such bump and if people really don’t care about the performance problem that might be okay. The silent downgrade path is however concerning.</div><div><br></div><div>Should we bump the bitcode version because of that change and have the autoupgrader properly rewrite the fast-math flags to </div><div>preserve the semantic and make sure there are no silent downgrade?</div><div><br></div><div><br></div><div>Thanks,</div><div>-Quentin</div></div><br></div></div><span class="">______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></span></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>