https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111335
Bug ID: 111335 Summary: fmaddpch seems not commutative for operands[1] and operands[2] due to precision loss Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: crazylht at gmail dot com Target Milestone: --- fmaddcph is complex _Float16 fma. cat test.c #include <immintrin.h> #include <cstdio> void func(_Float16 a[], _Float16 b[], _Float16 c[]) { const __m128h r0 = _mm_loadu_ph(a); const __m128h r1 = _mm_loadu_ph(b); const __m128h r2 = _mm_loadu_ph(c); const __m128h mul = _mm_fmadd_pch(r0, r1, r2); printf("%f %f\n", (float)mul[0], (float)mul[1]); } int main() { _Float16 a[8] = {-0.7949218f16, +0.2739257f16}; _Float16 b[8] = {+0.0010070f16, +0.0015659f16}; _Float16 c[8] = {-0.0010366f16, -0.0018014f16}; func(a, b, c); return 0; } g++ -O0 -march=sapphirerapids test.c, we get fmaddpch a, b, c, and the result is -0.002266 -0.002769 g++ -O0 -march=sapphirerapids test.c, we get fmaddpch b, a, c, and the result is -0.002266 -0.002771