Issue 143940
Summary Suboptimal register allocation when combining stores
Labels new issue
Assignees
Reporter neildhar
    I have the following function:

```
void foo(unsigned long long *base, unsigned long long *lim){
    while (base < lim){
        *(base++) = 0;
        *(base++) = 0;
        *(base++) = 0;
        *(base++) = 0;
        // Prevent emitting a call to memset
 asm volatile("");
    }
```

Clang generates the following for the loop:
```
.LBB0_2:
        add     x8, x0, #32
        stp     q0, q0, [x0]
        cmp     x8, x1
        mov     x0, x8
        b.lo .LBB0_2
```

However, the add and move seem to be unnecessary. The add can be avoided with a write-back in the store, so the loop can be more efficiently written as:

```
.LBB0_2:
        stp     q0, q0, [x0], #32
 cmp     x0, x1
        b.lo .LBB0_2
```

https://godbolt.org/z/acqMscs9K
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to