From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A774D3857C6F; Wed, 30 Dec 2020 09:35:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A774D3857C6F From: "ktkachov at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/98477] New: aarch64: Unnecessary GPR -> FPR moves for conditional select Date: Wed, 30 Dec 2020 09:35:35 +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: ktkachov 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: Wed, 30 Dec 2020 09:35:35 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98477 Bug ID: 98477 Summary: aarch64: Unnecessary GPR -> FPR moves for conditional select Product: gcc Version: unknown Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: ktkachov at gcc dot gnu.org Target Milestone: --- Target: aarch64 Code like void foo (int a, double *b) { *b =3D a ? 10000.0 : 200.0; } generates: foo: cmp w0, 0 mov x2, 149533581377536 movk x2, 0x40c3, lsl 48 mov x0, 4641240890982006784 fmov d0, x2 fmov d1, x0 fcsel d0, d0, d1, ne str d0, [x1] ret We don't need to do the FCSEL on the FPR side if we're just storing it to memory. We can just do a GPR CSEL and avoid the FMOVs. I've seen this pattern in the disassembly of some math library routines. Maybe we should add a =3Dw,w,w alternative to the CSEL patterns in the back= end?=