<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/115976>115976</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[DSE] `dereferenceable` attribute should be updated after shortening memset at the beginning
</td>
</tr>
<tr>
<th>Labels</th>
<td>
miscompilation,
llvm:transforms
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
dtcxzyw
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dtcxzyw
</td>
</tr>
</table>
<pre>
```
; bin/opt -passes=dse test.ll -S
define void @test(ptr %p) {
call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(100) %p, i8 0, i64 100, i1 false)
store i32 5, ptr %p, align 4
%4 = getelementptr inbounds i8, ptr %p, i64 4
store i32 8, ptr %4, align 4
%5 = getelementptr inbounds i8, ptr %p, i64 8
store i32 5, ptr %5, align 4
%6 = getelementptr inbounds i8, ptr %p, i64 12
store i32 8, ptr %6, align 4
ret void
}
```
```
define void @test(ptr %p) {
%1 = getelementptr inbounds i8, ptr %p, i64 16
call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(100) %1, i8 0, i64 84, i1 false)
store i32 5, ptr %p, align 4
%2 = getelementptr inbounds i8, ptr %p, i64 4
store i32 8, ptr %2, align 4
%3 = getelementptr inbounds i8, ptr %p, i64 8
store i32 5, ptr %3, align 4
%4 = getelementptr inbounds i8, ptr %p, i64 12
store i32 8, ptr %4, align 4
ret void
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0lOFumzAQx5_m-HJKZGxj4AMf2mR5gT6BgYN4MgbZplv39BOErlsWteqUSZEcfH_zvzO_Ox2C6R1RBdkjcN7G5vuPl2_AOWTHRM_xPPpq20zqsX2pQLHtx47AHkA8Ym0c8NM4RdxNOgQKII5tIIwU4t5a3D1dtC11xhE-j6ZFkGwJAy-m6BF4NgEvEfLHixSx0db-klr7POwHGgLF_cT2RsntoBtn11KHbnRutha1Nb1DiS156siTa0jXloAXKWOrw-p0QFMgW1clcQ0d0KTYaRsIePmaRIijJzSCY7Yo3lI9vDq9KoFnEkEcsadIlgZycVEbVy8ZBjTF9QsWZ_m30e86edso-7xR8X5F2W0j9XmjlL9fkrrh5CmuX3ojKj9uf65I-_PxUzABz9J_qEX9fxjTaxgLeQ8W-d1Z5LeNxN1ZFHfrro9YvNVeH7GYtJVoS1HqhKo0F6lUnCmWnCudatnqpusEq5syLxtqZFFmdZ2WKu9qnZiKMy7TNBUslSwr97LUQpVC56QKlesWJKNBG7tfARt9n5gQZqrSNCtzlVhdkw3bnB5MaMZhMlZHM7plXPMDcL6cBPEQvXahG_0QtkHuqyWyq-c-LACbEMObSzTRrvP_-PQFsiOCYtfEKoY6Rm_qORKG8zjbFmvCeWp1pBZ1F8kv-z6SM67HS3egjhjPhDX1xi37yextdY5xCiAegJ-An3oTz3O9b8YB-GlN_7LsJj9-pSYCP623EICftot4rvjPAAAA___iUvYp">