Issue 145399
Summary Store to potentially aliasing pointer causes LLVM to forget previously stored value
Labels missed-optimization, TBAA
Assignees
Reporter Kmeakin
    The second load of `x` is redundant because, even if `y` aliases with `x`, the final will still be `z`

https://godbolt.org/z/GKdPrPj6T
```c
int src(int* x, int* y, int z) {
    *x = z;
    *y = z;
    return *x;
}

int tgt(int* x, int* y, int z) {
    *x = z;
    *y = z;
 return z;
}
```

```asm
src:
        str     w2, [x0]
        str w2, [x1]
        ldr     w0, [x0]
        ret

tgt:
        str     w2, [x0]
        mov     w0, w2
        str     w2, [x1]
        ret
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to