From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 51DF03858D20; Tue, 31 Oct 2023 04:48:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 51DF03858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1698727703; bh=/H8C8GvO8VYrZP6tAGkTZrhxSSemYlCGTHqyaReNHHE=; h=From:To:Subject:Date:From; b=C0sLtANAAtE+jnEgYjgMvyOMCtcbHtFHf2jndfYIbuS8RBnSZFCi2iPXx359GM1zC N5lV8msnQthNrbtb1LnLA9CRbz4hSM++7Xoaolz+O5F188KJF8o4f0f96av7v5haoQ hKNxkcZUBW0/7p5sNBD/0zp2GffYfEEWDeGqAnc8= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/112304] New: cinc is not being used for (small) constant Date: Tue, 31 Oct 2023 04:48:23 +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: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: pinskia 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112304 Bug ID: 112304 Summary: cinc is not being used for (small) constant Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: target Assignee: pinskia at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Target: aarch64-linux-gnu Take: ``` int f(int a) { return (a!=3D0)+42; } int f1(int a, int b) { return (a!=3D0)+b; } ``` Currently we get: ``` f: cmp w0, 0 cset w0, ne add w0, w0, 42 ret f1: cmp w0, 0 cinc w0, w1, ne ret ``` But f should really be: ``` mov w1, #42 cmp w0, #0 cinc w0, w1, ne ret ``` Because for many newer aarch64 cores the `mov` in this case is "free" and d= oes not take up an issue slot or even the for a dual issue, the mov and cmp cou= ld be issued together. Even though it is the same # of instruction, the second case is going to be faster due to latencies.=