public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/108840] New: Aarch64 doesn't optimize away shift counter masking
@ 2023-02-17 17:59 jakub at gcc dot gnu.org
  2023-02-17 18:08 ` [Bug target/108840] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-02-17 17:59 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108840
           Summary: Aarch64 doesn't optimize away shift counter masking
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

As mentioned in 
https://gcc.gnu.org/pipermail/gcc-patches/2023-February/612214.html
aarch64 doesn't optimize away and instructions masking shift count if there is
more than one shift with the same count.  Consider -O2 -fno-tree-vectorize:
int
foo (int x, int y)
{
  return x << (y & 31);
}

void
bar (int x[3], int y)
{
  x[0] <<= (y & 31);
  x[1] <<= (y & 31);
  x[2] <<= (y & 31);
}

void
baz (int x[3], int y)
{
  y &= 31;
  x[0] <<= y;
  x[1] <<= y;
  x[2] <<= y;
}

void corge (int, int, int);

void
qux (int x, int y, int z, int n)
{
  n &= 31;
  corge (x << n, y << n, z >> n);
}

foo is optimized correctly, combine matches the shift with masking, but in the
rest of cases due to costs the desirable combination is rejected.  Shift with
embedded masking of the count should have rtx_cost the same as normal shift
when it is actually under the hood the shift itself.

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

end of thread, other threads:[~2023-04-19  8:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-17 17:59 [Bug target/108840] New: Aarch64 doesn't optimize away shift counter masking jakub at gcc dot gnu.org
2023-02-17 18:08 ` [Bug target/108840] " pinskia at gcc dot gnu.org
2023-02-21 12:24 ` ktkachov at gcc dot gnu.org
2023-02-24 15:37 ` ktkachov at gcc dot gnu.org
2023-04-19  8:35 ` cvs-commit at gcc dot gnu.org
2023-04-19  8:37 ` ktkachov at gcc dot gnu.org

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).