<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I'm not sure why this is an issue.  Yes, these two intrinsics depend<br>on the current rounding mode according to the C standard, and yes,<br>LLVM in default mode assumes that the current rounding mode is the<br>default rounding mode.  But the same holds true for many other<br>intrinsics and even the arithmetic IR operations like add.</blockquote><div><br></div>Any other intrinsic, like `floor`, `round` etc has meaning at default rounding mode. But use of `rint` or `nearbyint` in default FP environment is strange, `roundeven` can be used instead. We could use more general intrinsics in all cases, as the special case of default environment is not of practical interest.<div><br></div><div>There is another reason for special handling. Set of intrinsics includes things like `x86_sse_cvtss2si`. It is unlikely that all of them eventually get constrained counterpart. It looks more natural that such intrinsics are defined as accessing FP environment and can be optimized if the latter is default. These two intrinsics could be a good model for such cases. IIUC, splitting entities into constrained or non-constrained is a temporary solution, ideally they will merge into one entity. We could do it for some intrinsics now.<br><div> <br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Thanks,<br>--Serge<br></div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 2, 2020 at 8:58 PM Ulrich Weigand <<a href="mailto:Ulrich.Weigand@de.ibm.com">Ulrich.Weigand@de.ibm.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><p><tt><font size="2">Serge Pavlov <<a href="mailto:sepavloff@gmail.com" target="_blank">sepavloff@gmail.com</a>> wrote on 02.03.2020 14:38:48:<br><br>> This approach has issues when applied to the intrinsics `rint` and <br>> `nearbyint`. Value returned by either of these intrinsics depends on<br>> current rounding mode. If they are considered as operation in <br>> default environment, they would round only to nearest. It is by far <br>> not the meaning of the standard C functions that these intrinsics represent.<br></font></tt><br><tt><font size="2">I'm not sure why this is an issue.  Yes, these two intrinsics depend</font></tt><br><tt><font size="2">on the current rounding mode according to the C standard, and yes,</font></tt><br><tt><font size="2">LLVM in default mode assumes that the current rounding mode is the</font></tt><br><tt><font size="2">default rounding mode.  But the same holds true for many other</font></tt><br><tt><font size="2">intrinsics and even the arithmetic IR operations like add.</font></tt><br><br><tt><font size="2">If you want to stop clang from making the default rounding mode</font></tt><br><tt><font size="2">assumption, you need to use the -frounding-math option (or one</font></tt><br><tt><font size="2">of its equivalents), which will cause clang to emit the corresponding</font></tt><br><tt><font size="2">constrained intrinsics instead, for those two as well all other</font></tt><br><tt><font size="2">affected intrinsics.</font></tt><br><br><tt><font size="2">I don't see why it would make sense to add another special case</font></tt><br><tt><font size="2">just for those two intrinsics ...</font></tt><br><br><br><tt><font size="2">Bye,</font></tt><br><tt><font size="2">Ulrich</font></tt><br><br>
</p></div>
</blockquote></div>