From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0618D3857006; Wed, 6 Sep 2023 12:18:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0618D3857006 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694002735; bh=rSNKxlnIXh3Zg9cqmOd59uTQ75fTALp1aiK6nW6IDTo=; h=From:To:Subject:Date:From; b=w5H1iuSx+p8luaVbMMvp5gJCcKQFOgdr7dU5FzRKPul2BNp9C1g1b2s3DIoxUUQie 836hCmsYzrT90mC7raz4xwrRwjlEzFTRJSMvgoMw1qes+Wv5tPzl5oaY6/JFyWhMoK 35W/eUfcIRNL74aQdQq8H3JPiLAQthZjK0/7dodU= From: "joony.wie at samsung dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111306] New: macro-fusion makes error on conjugate complex multiplication Date: Wed, 06 Sep 2023 12:18:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: joony.wie at samsung dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111306 Bug ID: 111306 Summary: macro-fusion makes error on conjugate complex multiplication Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: joony.wie at samsung dot com Target Milestone: --- It seems that the operands src1 and src2 of "_mm512_fcmul_pch" are swapped = for macro-fusion with optimize option. If the operands are swapped, the imag value of result will have incorrect s= ign bit. So, the operands should not be swapped in these conjugate complex multiplication intrinsics. Let me show the example and the output. output:=20 3.000000 -4.000000 // w/o optimize. 3.000000 4.000000 // w/ optimize. https://godbolt.org/z/df9Gz18hc // but may not executable ``` #include #include __attribute__((optimize("O0"))) auto func0(_Float16 *a, _Float16 *b, int n, _Float16 *c) { __m512h rA =3D _mm512_loadu_ph(a); for (int i =3D 0; i < n; i +=3D 32) { __m512h rB =3D _mm512_loadu_ph(b + i); _mm512_storeu_ph(c + i, _mm512_fcmul_pch(rB, rA)); } } __attribute__((optimize("O"))) auto func1(_Float16 *a, _Float16 *b, int n, _Float16 *c) { __m512h rA =3D _mm512_loadu_ph(a); for (int i =3D 0; i < n; i +=3D 32) { __m512h rB =3D _mm512_loadu_ph(b + i); _mm512_storeu_ph(c + i, _mm512_fcmul_pch(rB, rA)); } } int main() { int n =3D 32; _Float16 a[n], b[n], c[n]; for (int i =3D 1; i <=3D n; i++) { a[i - 1] =3D i & 1 ? -i : i; b[i - 1] =3D i; } func0(a, b, n, c); for (int i =3D 0; i < n / 32 * 2; i++) { printf("%f ", (float)c[i]); } printf("\n"); func1(a, b, n, c); for (int i =3D 0; i < n / 32 * 2; i++) { printf("%f ", (float)c[i]); } printf("\n"); return 0; } ```=