[llvm] [AArch64] Optimize when storing symmetry constants (PR #93717)

NAKAMURA Takumi via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 22 03:06:44 PDT 2024


chapuni wrote:

I've created a minimal testcase.

```
int f(unsigned long *s, const unsigned long *l) {
  *s = 0x1234567812345678UL;
  return *l == 0x1234567812345678UL;
}
```

Before
```
        mov     x8, #22136                      // =0x5678
        movk    x8, #4660, lsl #16
        orr     x8, x8, x8, lsl #32 // Creates symmetric i64 onto x8
        str     x8, [x0]
        ldr     x9, [x1]
        cmp     x9, x8 // Assumes x8 is symmetric i64
        cset    w0, eq
        ret
```

After
```
        mov     x8, #22136                      // =0x5678
        movk    x8, #4660, lsl #16
        stp     w8, w8, [x0]
        ldr     x9, [x1]
        cmp     x9, x8 // Supposes x8 is symmetric i64
        cset    w0, eq
        ret
```


https://github.com/llvm/llvm-project/pull/93717


More information about the llvm-commits mailing list