- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sample code:
#include <fenv.h>
#include <math.h>
#if __STDC__ == 1 && __STDC_IEC_559__ == 1
#pragma STDC FENV_ACCESS ON
int main(void)
{
sin(0.5);
return fetestexcept(FE_INEXACT) ? 0 : 1;
}
#endif
-std=c11 -Wall -Wextra -fp-model=strict -O2
Generated code:
main:
push rbp #9.1
mov rbp, rsp #9.1
and rsp, -128 #9.1
xor edi, edi #9.1
xor esi, esi #9.1
call __intel_new_feature_proc_init #9.1
mov edi, 32 #11.12
call fetestexcept
Here we see that call sin
was incorrectly optimized out.
Tool version: icc 2021.1.2 on Linux on x86-64
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for posting in Intel Communities.
O2 optimization will give the maximum optimization. In this case, as you're not using the value of sin(0.5) anywhere else in the code, so it was optimized out, and as a result, you're not able to see it in the assembly code.
However, if you use the sin value somewhere in the code, then you will also be able to see the step in the assembly code.
I've tried printing the value of sin(0.5) hence, after compilation, I can see the step in the assembly code.
For your reference, I've attached screenshots of the source code as well as the assembly code that is being generated after the addition of the print statement.
Thanks and Regards,
Ditipriya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
C11, F.9.1 Global transformations:
> Floating-point arithmetic operations and external function calls may entail side effects which optimization shall honor, at least where the state of the FENV_ACCESS pragma is ‘‘on’’.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Per documentation does Intel C compiler conform to the specifications in the Annex F under -fp-model=strict?
If no, then for which purpose it defines __STDC_IEC_559__ to 1 under -fp-model=strict?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
The original query has been answered and the follow up query is the same as the query in the given URL.
Can you please let us know if we can go ahead and close the thread?
Thanks and Regards,
Ditipriya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We have not heard back from you. This thread will no longer be monitored by Intel. If you need further assistance, please post a new question.
Thanks & Regards,
Ditipriya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@DitiD_Intel The follow up query (1) is _not_ the same as the query in the given URL (2):
- (1): issue regarding strict floating-point model
- (2): issue regarding non-strict floating-point models
So we need to go ahead and:
1. Answer the question: "Per documentation does Intel C compiler conform to the specifications in the Annex F under -fp-model=strict?"
2. If the answer is "yes", then fix the bug (see title).
3. If the answer is "no", then remove definition of __STDC_IEC_559__ to 1. (Because otherwise it is unclear, for which purpose it defines __STDC_IEC_559__ to 1 under -fp-model=strict.)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page