[PATCH] D87528: Enable '#pragma STDC FENV_ACCESS' in frontend cf. D69272 - Work in Progress

Serge Pavlov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 29 01:14:58 PDT 2020


sepavloff added a comment.

In D87528#2299497 <https://reviews.llvm.org/D87528#2299497>, @mibintc wrote:

> In D87528#2297647 <https://reviews.llvm.org/D87528#2297647>, @sepavloff wrote:
>
>> In D87528#2295015 <https://reviews.llvm.org/D87528#2295015>, @mibintc wrote:
>>
>>> I tried using the 0924 version of the patch on an internal workload SPEC "cpu2017" and found that a few files failed to compile because of an error message on static initializer, like this: struct s { float f; }; static struct s x = {0.63};   Compiled with ffp-model=strict "initializer..is not a compile-time constant"
>>
>> Thank you for trying this.
>>
>> The error happens because static variable initializer gets rounding mode calculated from command-line options (`dynamic`), but this is wrong because such initializers must be calculated using constant rounding mode (`tonearest` in this case). Either we must force default FP mode in such initializers, or we are wrong when using `FPOptions::defaultWithoutTrailingStorage`. Need to analyze this problem more.
>
> @sepavloff Please provide precise reference to support the claim "but this is wrong because such initializers must be calculated using constant rounding mode..."  many thanks!

>From http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2478.pdf:

**6.7.9 Initialization**
…
4 All the expressions in an initializer for an object that has static or thread storage duration shall be
constant expressions or string literals.

**6.6 Constant expressions**
…
2 A constant expression can be evaluated during translation rather than runtime, and accordingly
may be used in any place that a constant may be.

**F.8.2 Translation**
1 During translation, constant rounding direction modes (7.6.2) are in effect where specified. Elsewhere,
during translation the IEC 60559 default modes are in effect:

- The rounding direction mode is rounding to nearest.

…

**7.6.2 The FENV_ROUND pragma**
…
2 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. …


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87528/new/

https://reviews.llvm.org/D87528



More information about the cfe-commits mailing list