[llvm-bugs] [Bug 46694] New: [AArch64] use rev16 with load/store merging patterns

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jul 12 11:57:32 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46694

            Bug ID: 46694
           Summary: [AArch64] use rev16 with load/store merging patterns
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: AArch64
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: arnaud.degrandmaison at arm.com,
                    llvm-bugs at lists.llvm.org, smithp352 at googlemail.com,
                    Ties.Stuij at arm.com

struct edge {
    unsigned char from;
    unsigned char to;
};

void reverse_edge_inplace(struct edge *e) {
    unsigned char tmp = e->from;
    e->from = e->to;
    e->to = tmp;
}

void reverse_edge_src_dst(const struct edge *src, struct edge *dst) {
    struct edge e = *src;

    unsigned char tmp = e.from;
    e.from = e.to;
    e.to = tmp;

    *dst = e;
}

This is the same example as bug 41098 but targeted specifically at an AArch64
opportunity:
https://godbolt.org/z/xbaf3M

As seen in the gcc output, we can trade 1 load + 1 store for a rev16:
  ldrb w8, [x0, #1]
  ldrb w9, [x0]
  strb w8, [x0]
  strb w9, [x0, #1]

vs.
  ldrh w1, [x0]
  rev16 w1, w1
  strh w1, [x0]

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200712/203f1b5e/attachment.html>


More information about the llvm-bugs mailing list