<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/145399>145399</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Store to potentially aliasing pointer causes LLVM to forget previously stored value
</td>
</tr>
<tr>
<th>Labels</th>
<td>
missed-optimization,
TBAA
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Kmeakin
</td>
</tr>
</table>
<pre>
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
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0U02PozgQ_TXFpdSRMQHCgQPZKHvoXqmlbe3d4EriXmNHdpGvXz9ykp7-0MxIcxiEsF316r16yKViNFtH1EK5hHKVqYl3PrSPI6n_jct6r8_ty44w0uCdRuuVRr9BqMQJKoEmYiA9Oa0cY0-DmiKB_AvpQA7NFXdOOGWNihTxaHj3VpxwvCPcGKcsHo21GDl9e0qQS4KIDkS3Y95HKDqQa5Drrde9tzzzYQtyfQG5_vtRP4fn1-olwStxewcQnXGMMQwgF8YxyA5PSfO-P9_3eAHZINRLEB0iIsjuhFCs8ALFh9j5aywQT8Fd4bcg1Ktbv4mUt_wHZO-al0-Cb45v4t-PKo4gumS_6O586YkcrutRpkagXJ4ElKsvgPdk_jlp9b1a_KQ6EN_6SD_g94RHf_jAfZS_rM1_KPvmPdNtoZuiURm1eV2KWizqcp7t2qqs5VCooa_yuqKqrhdCV8WmULovtBI6M60UshSVLPKmbPJi1pCiXhR6ni8EqWYBc0GjMnZm7WFMlzAzMU7U5vOyaJrMqp5svE6TlKOJkfSD37MZzUWx8Q5ksgBSviy7Lh3KVRbaxPXQT9sIc2FN5PjOzoYttf-yD4Tsce-ZHBtl7fk2VMZtce-NYwp4Hb-IT0___ZOwGx-2xLgPdDB-ivaMMdFoPCg7UTYF234ZLcO7qZ8NfgS5Th3cl4d98K80MMj11WwEub77PbTyWwAAAP__qQMzcg">