]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
docs: Document that __builtin_assoc_barrier also can be used for FMAs [PR115023]
authorAndrew Pinski <quic_apinski@quicinc.com>
Sun, 3 Nov 2024 06:34:00 +0000 (23:34 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Sun, 3 Nov 2024 18:51:29 +0000 (10:51 -0800)
I noticed that __builtin_assoc_barrier makes a differnce for FMAs formation
but it was not documented. This adds that documentation even with a small example.

Build the HTML documents to make sure everything looks correct.

gcc/ChangeLog:

PR middle-end/115023
* doc/extend.texi (__builtin_assoc_barrier): Document ffp-contract=fast
and FMA usage.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/doc/extend.texi

index ad1821e3e23cb4138e4814cb0e0913e0c254343a..5902e76f043bc54cb06519cce4c2e943d6e17c8f 100644 (file)
@@ -15555,8 +15555,7 @@ This built-in inhibits re-association of the floating-point expression
 @var{expr} with expressions consuming the return value of the built-in. The
 expression @var{expr} itself can be reordered, and the whole expression
 @var{expr} can be reordered with operands after the barrier. The barrier is
-only relevant when @code{-fassociative-math} is active, since otherwise
-floating-point is not treated as associative.
+relevant when @code{-fassociative-math} is active.
 
 @smallexample
 float x0 = a + b - b;
@@ -15566,6 +15565,19 @@ float x1 = __builtin_assoc_barrier(a + b) - b;
 @noindent
 means that, with @code{-fassociative-math}, @code{x0} can be optimized to
 @code{x0 = a} but @code{x1} cannot.
+
+It is also relevant when @code{-ffp-contract=fast} is active;
+it will prevent contraction between expressions.
+
+@smallexample
+float x0 = a * b + c;
+float x1 = __builtin_assoc_barrier (a * b) + c;
+@end smallexample
+
+@noindent
+means that, with @code{-ffp-contract=fast}, @code{x0} may be optimized to
+use a fused multiply-add instruction but @code{x1} cannot.
+
 @enddefbuiltin
 
 @defbuiltin{{void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)}