From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EBAD0385781F; Wed, 4 Oct 2023 20:52:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EBAD0385781F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696452754; bh=i01DfENfov9nWnYZGKkPU1ikA0qpqfeOSHBY492F0Bo=; h=From:To:Subject:Date:From; b=HvBN9JOMbQSnvkVF74T51/2VGlh/A4r4ZMeE7Y56UegjcWWxsNRtOb7yhiWYVTwk9 YAJg970yPmgNFPzyMK2Ix9fsgDllfCRe8ywljJDPT+SA9UqUA4TClrMjaMAzxdYSJc eyqvAECEQeB8uCcKhhKbb2QrUDaj0bCoQIPtxgG4= From: "ubizjak at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/111698] New: Narrow memory access of compare to byte width Date: Wed, 04 Oct 2023 20:52:34 +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.3.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ubizjak 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111698 Bug ID: 111698 Summary: Narrow memory access of compare to byte width Product: gcc Version: 12.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: ubizjak at gmail dot com Target Milestone: --- Following testcase: --cut here-- int m; _Bool foo (void) { return m & 0x0f0000; } --cut here-- compiles to: 0: f7 05 00 00 00 00 00 testl $0xf0000,0x0(%rip) 7: 00 0f 00=20 The test instruction can be demoted to byte test from addr+2. Currently, the demotion works for lowest byte, so the testcase: --cut here-- int m; _Bool foo (void) { return m & 0x0f; } --cut here-- compiles to: 0: f6 05 00 00 00 00 0f testb $0xf,0x0(%rip) which is three bytes shorter. Any half-way modern Intel and AMD cores will forward any fully contained lo= ad, so there is no danger of forwarding stall with recent CPU cores.=