From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EDAC83857C77; Thu, 11 Mar 2021 13:19:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EDAC83857C77 From: "nsz at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/99551] New: aarch64: csel is used for cold scalar computation which affects performance Date: Thu, 11 Mar 2021 13:19:10 +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: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: nsz 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 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 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: Thu, 11 Mar 2021 13:19:11 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99551 Bug ID: 99551 Summary: aarch64: csel is used for cold scalar computation which affects performance Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: nsz at gcc dot gnu.org Target Milestone: --- this is an optimization bug, i don't know which layer it should be fixed so i report it as target bug. cold path affects performance of hot code because csel is used: long foo(long x, int c) { if (__builtin_expect(c,0)) x =3D (x + 15) & ~15; return x; } compiles to foo: cmp w1, 0 add x1, x0, 15 and x1, x1, -16 csel x0, x1, x0, ne ret i think it would be better to use a branch if the user explicitly marked the computation cold. e.g. this is faster if c is always 0: long foo(long x, int c) { if (__builtin_expect(c,0)) { asm (""); x =3D (x + 15) & ~15; } return x; } foo: cbnz w1, .L7 ret .L7: add x0, x0, 15 and x0, x0, -16 ret=