<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Note that it can be implemented by multiple calls to fegetround and fesetround, but it need not be. For example, on machines with AVX-512 support, a compiler might use the static rounding modes on individual floating-point instructions to implement the desired semantics.<div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Mar 5, 2021, at 4:47 PM, Steve (Numerics) Canon via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">FENV_ROUND applies to all floating-point operations in its scope, not the compiler.<div class=""><br class=""></div><div class="">It is not equivalent to a call to fesetround(), because it does not propagate into any calls that take control out of the source language scope of the pragma. If the direction is anything other than FE_DYNAMIC, every operation in the block is to be performed in the specified mode, regardless of the dynamic rounding mode set by any calls to fesetround or inherited from the environment. If it is FE_DYNAMIC, every operation in the block is to be performed according to the dynamic rounding mode set by a call to fesetround.</div><div class=""><br class=""></div><div class="">– Steve<br class=""><div class=""><div class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Mar 5, 2021, at 3:30 PM, Kevin Neal via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta charset="UTF-8" class=""><font face="Courier New" size="2" style="caret-color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="font-size: 11pt;" class=""><div class="">I’m looking at #pragma STDC FP_ROUND in n2596. It isn’t clear to me that the pragma is supposed to only apply to the compiler, or if the compiler is required to change the floating point environment when the compiled code is executed.</div><div class=""> </div><div class="">The draft says: “The FENV_ROUND pragma provides a means to specify a constant rounding direction for floating point operations for standard floating types within a translation unit or compound statement.”</div><div class=""><font face="Calibri" class=""> </font></div><div class="">Use of the word “constant” sounds to me like it only applies to constants. Especially since the next paragraph contrasts the “constant rounding mode” with the “dynamic rounding mode”. The “constant rounding mode” does not apply to functions that are called from a place where the #pragma is in effect.</div><div class=""> </div><div class="">On the other hand, paragraph 4 starts out with “The FENV_ROUND pragma affects operations for standard floating types. Within the scope of an FENV_ROUND pragma establishing a mode other than FE_DYNAMIC, floating-point operators, implicit conversions...”</div><div class=""><font face="Calibri" class=""> </font></div><div class="">That paragraph doesn’t sound like the #pragma is restricted to operations on constants. Plus, there’s a block of example code showing that the compiler “could” insert calls to fesetround().<span class="Apple-converted-space"> </span></div><div class=""> </div><div class="">So which is it? Is this pragma equivalent to a call to fesetround() or not?</div></span></font></div></blockquote><br class=""></div></div></div></div></div>_______________________________________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev<br class=""></div></blockquote></div><br class=""></div></body></html>