From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AD3253858401; Fri, 15 Oct 2021 21:07:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AD3253858401 From: "christophm30 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/102793] New: AArch64: sequential comparisons with equal conditional blocks don't use ccmp Date: Fri, 15 Oct 2021 21:07:50 +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: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: christophm30 at gmail 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 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, 15 Oct 2021 21:07:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102793 Bug ID: 102793 Summary: AArch64: sequential comparisons with equal conditional blocks don't use ccmp Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: christophm30 at gmail dot com Target Milestone: --- The following code: int ccmp(uint64_t* s1, uint64_t* s2, int(*foo)(void)) { uint64_t d1, d2, bar; d1 =3D *s1++; d2 =3D *s2++; bar =3D (d1 ^ d2) & 0xabcd; if (bar =3D=3D 0 || d1 !=3D d2) return foo(); return 0; } int noccmp(uint64_t* s1, uint64_t* s2, int(*foo)(void)) { uint64_t d1, d2, bar; d1 =3D *s1++; d2 =3D *s2++; bar =3D (d1 ^ d2) & 0xabcd; if (bar =3D=3D 0) return foo(); if (d1 !=3D d2) return foo(); return 0; } ...produces (GCC master or earlier, ARM64, with -O3): ccmp: ldr x3, [x0] mov x4, 43981 ldr x0, [x1] eor x1, x3, x0 tst x1, x4 ccmp x3, x0, 0, ne bne .L5 mov w0, 0 ret .L5: mov x16, x2 br x16 noccmp: ldr x3, [x0] mov x4, 43981 ldr x0, [x1] eor x1, x3, x0 tst x1, x4 beq .L8 cmp x3, x0 beq .L9 .L8: mov x16, x2 br x16 .L9: mov w0, 0 ret Since both conditional blocks do exactly the same (they call foo()), both functions could use the ccmp instruction. I just observed this and have not analysed this any further.=