Skip to content

[AArch64] Optimize the offset of memory access #71917

@vfdff

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.

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