public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/111698] New: Narrow memory access of compare to byte width
@ 2023-10-04 20:52 ubizjak at gmail dot com
  2023-10-05  7:51 ` [Bug target/111698] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: ubizjak at gmail dot com @ 2023-10-04 20:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111698

            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 

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 load,
so there is no danger of forwarding stall with recent CPU cores.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-10-25 14:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-04 20:52 [Bug target/111698] New: Narrow memory access of compare to byte width ubizjak at gmail dot com
2023-10-05  7:51 ` [Bug target/111698] " rguenth at gcc dot gnu.org
2023-10-05 11:29 ` ubizjak at gmail dot com
2023-10-24 12:12 ` ubizjak at gmail dot com
2023-10-25 14:28 ` cvs-commit at gcc dot gnu.org
2023-10-25 14:30 ` ubizjak at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).