From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B4F61385B804; Fri, 6 May 2022 09:12:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4F61385B804 From: "amonakov at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/105504] New: Fails to break dependency for vcvtss2sd xmm, xmm, mem Date: Fri, 06 May 2022 09:12:40 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: unknown X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: amonakov at gcc dot gnu.org 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 keywords bug_severity priority component assigned_to reporter target_milestone attachments.created 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 May 2022 09:12:40 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105504 Bug ID: 105504 Summary: Fails to break dependency for vcvtss2sd xmm, xmm, mem Product: gcc Version: unknown Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: amonakov at gcc dot gnu.org Target Milestone: --- Created attachment 52933 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D52933&action=3Dedit testcase Hit by core-math team at https://gcc.gnu.org/pipermail/gcc-help/2022-May/141480.html Compile the attached testcase with -O2 -march=3Dhaswell (other AVX-capable = Intel families except Alderlake are affected too) and observe that the big basic block begins with .L6: vcvtss2sd xmm1, xmm1, DWORD PTR [rsp-4] This creates a false dependency on the previous assignment into xmm1, resul= ting in wildly varying (and suboptimal) throughput figures depending on how long= the CPU stalls waiting for the previous assignment to complete. GCC has code to emit such instructions in a manner that avoids false dependencies (see e.g. PR89071), but here it doesn't seem to work. Also there's a potentially related issue that GCC copies the initial xmm0 v= alue to eax via stack in the beginning of the function: cr_exp10f: vmovss DWORD PTR [rsp-4], xmm0 mov eax, DWORD PTR [rsp-4] This seems wrong since xmm-reg moves on Haswell are 1 cycle afaict.=