public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Questions] Is there any bit in gimple/rtl to indicate this IR support fast-math or not?
@ 2021-07-14  5:15 Hongtao Liu
  2021-07-14  5:18 ` Hongtao Liu
       [not found] ` <47833128.jc7mZyZMxp@excalibur>
  0 siblings, 2 replies; 10+ messages in thread
From: Hongtao Liu @ 2021-07-14  5:15 UTC (permalink / raw)
  To: gcc-help, GCC Patches, GCC Development

Hi:
  The original problem was that some users wanted the cmdline option
-ffast-math not to act on intrinsic production code. .i.e for codes
like

#include<immintrin.h>
__m256d
foo2 (__m256d a, __m256d b, __m256d c, __m256d d)
{
__m256d tmp = _mm256_add_pd (a, b);
tmp = _mm256_sub_pd (tmp, c);
tmp = _mm256_sub_pd (tmp, d);
return tmp;
}

compiled with -O2 -mavx2 -ffast-math, users expected codes generated like

vaddpd ymm0, ymm0, ymm1
vsubpd ymm0, ymm0, ymm2
vsubpd ymm0, ymm0, ymm3

but not

vsubpd ymm1, ymm1, ymm2
vsubpd ymm0, ymm0, ymm3
vaddpd ymm0, ymm1, ymm0


For the LLVM side, there're mechanisms like
#pragma float_control( precise, on, push)
...(intrinsics definition)..
#pragma float_control(pop)

When intrinsics are inlined, their IRs will be marked with
"no-fast-math", and even if the caller is compiled with -ffast-math,
reassociation only happens to those IRs which are not marked with
"no-fast-math". It seems to be more flexible to support fast math
control of a region(inside a function).

Does GCC have a similar mechanism?


-- 
BR,
Hongtao

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-07-19  7:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-14  5:15 [Questions] Is there any bit in gimple/rtl to indicate this IR support fast-math or not? Hongtao Liu
2021-07-14  5:18 ` Hongtao Liu
2021-07-14  6:39   ` Matthias Kretz
2021-07-14  7:04     ` Hongtao Liu
2021-07-14  7:39       ` Richard Biener
2021-07-14 16:45         ` Segher Boessenkool
     [not found] ` <47833128.jc7mZyZMxp@excalibur>
     [not found]   ` <CAFiYyc2t690=B77Mwb9=-T_TzQvZUj7RnFVDmuaWDJBN81DtHw@mail.gmail.com>
2021-07-16  8:57     ` [RFC] c-family: Add __builtin_noassoc Matthias Kretz
2021-07-16  9:31       ` Richard Biener
2021-07-16 12:00         ` Matthias Kretz
2021-07-19  7:16           ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).