[Bug target/105773] New: [Aarch64] Failure to optimize and+cmp to tst

gabravier at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon May 30 13:29:04 GMT 2022


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

            Bug ID: 105773
           Summary: [Aarch64] Failure to optimize and+cmp to tst
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

int
baz (unsigned long x, unsigned long y)
{
  return (int) (x & y) > 0;
}

With -O3, AArch64 GCC outputs this:

baz(unsigned long, unsigned long):
        and     w0, w0, w1
        cmp     w0, 0
        cset    w0, gt
        ret

whereas LLVM outputs this:

baz(unsigned long, unsigned long):
        tst     w1, w0
        cset    w0, gt
        ret

It seems to me as though using tst should be faster (unless Aarch64 processors
are extremely weird).


More information about the Gcc-bugs mailing list