From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 86FF23857369; Sat, 7 May 2022 08:24:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 86FF23857369 From: "amonakov at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/105513] New: [9/10/11/12/13 Regression] Unnecessary SSE spill Date: Sat, 07 May 2022 08:24:29 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: unknown X-Bugzilla-Keywords: missed-optimization, ra 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 cf_gcctarget 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: Sat, 07 May 2022 08:24:29 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105513 Bug ID: 105513 Summary: [9/10/11/12/13 Regression] Unnecessary SSE spill Product: gcc Version: unknown Status: UNCONFIRMED Keywords: missed-optimization, ra Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: amonakov at gcc dot gnu.org Target Milestone: --- Target: x86_64-*-* i?86-*-* Minimized from PR 105504. Compile with -O2 -mtune=3Dhaswell -mavx (other -mtune variants are affected= too): static int as_int(float x) { return (union{float x; int i;}){x}.i; } float f(double y, float x) { int i =3D as_int(x); if (__builtin_expect(i > 99, 0)) return 0; if (i*2u < 77) if (i=3D=3D2) return 0; return y*x; } GCC moves 'x' to 'i' via stack and then reloads from stack again when compu= ting 'y*x': f: vmovss DWORD PTR [rsp-4], xmm1 mov eax, DWORD PTR [rsp-4] cmp eax, 99 jg .L5 lea edx, [rax+rax] cmp edx, 76 ja .L6 cmp eax, 2 je .L5 .L6: vcvtss2sd xmm1, xmm1, DWORD PTR [rsp-4] vmulsd xmm0, xmm1, xmm0 vcvtsd2ss xmm0, xmm0, xmm0 ret .L5: vxorps xmm0, xmm0, xmm0 ret This is a regression relative to gcc-8. Interestingly, flipping '0' to '1' = in __builtin_expect (i.e. making early exit likely) results in good code, so perhaps RA costing takes block probabilities backwards somewhere?=