Skip to content

[AArch64] Optimize the offset of memory access #71917

Description

@vfdff
int testOffset(char a[]) {
  return a[0xfde78];
}
  • gcc:
testOffset(char*):
        add     x0, x0, 1036288
        ldrb    w0, [x0, 3704]
        ret
  • llvm:
testOffset(char*):                       // @testOffset(char*)
        mov     w8, #56952                      // =0xde78
        movk    w8, #15, lsl #16
        ldrb    w0, [x0, x8]
        ret
  • Gcc using base addressing produces more efficient instructions than llvm using index addressing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions