<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62459>62459</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MergeICmps] Correctness related to eq-chain comparisons
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
vfdff
</td>
</tr>
</table>
<pre>
* the following case can't be merged into a memcpy as the address of the comparison value is **not** from small to large.
* test: https://alive2.llvm.org/ce/z/72iZnh
```
define i1 @src(ptr nocapture noundef nonnull readonly align 4 dereferenceable(24) %0,
ptr nocapture noundef nonnull readonly align 4 dereferenceable(24) %1) {
bb1: ; preds = %bb0
%s2 = getelementptr inbounds %"c", ptr %0, i64 0, i32 1
%v2 = load i32, ptr %s2, align 4
%s3 = getelementptr inbounds %"c", ptr %1, i64 0, i32 1
%v3 = load i32, ptr %s3, align 4
%cmp1 = icmp eq i32 %v2, %v3
br i1 %cmp1, label %bb2, label %bb3
bb2: ; preds = %bb1
%s4 = getelementptr inbounds %"c", ptr %0, i64 0, i32 0
%v4 = load i32, ptr %s4, align 4
%s5 = getelementptr inbounds %"c", ptr %1, i64 0, i32 0
%v5 = load i32, ptr %s5, align 4
%cmp2 = icmp eq i32 %v4, %v5
br label %bb3
bb3: ; preds = %bb2, %bb1, %bb0
%cmp3 = phi i1 [ false, %bb1 ], [ %cmp2, %bb2 ]
ret i1 %cmp3
}
```
* the issue is first reported on D141188, I raise it as this is a potential runtime issue based on the current upstream version.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVdGO6jgM_ZrwYg1qnbSUhz7AIKT7sD-wb2nqQlZp0pukrGa_fpWU3mGuhiuNNAjRGMcnxz6pLUPQF0vUsurIqtNGzvHqfHsb-mHYdK5_axkeIF4JBmeM-1fbCygZCJS0DHcROoKR_IV60DY6kDDSqKY3kCFHyb73FAK4IZvKjZP0OjgLN2lmAh2A4YHhwbq4LGDwboQwSmMgOjDSX2jLihMrsjdSiIwf4BrjFBg_MDwzPEujb4RbY27j1vkLw7Mihuf_GJ53qP-21ztAXdy_2exp0JZAl8BEEbxi2EzRg3VKTnH2BNbNtqcBrLN2NgY8yd5Z8wbS6IsFAT15GsiTVSQ7QwwbFAz3wLAqGL4ux8D3gZb5uTsuwF1XplJ88cP4ESZPfQDGTwm06-71SEbA_PeFIhkaycZEXtsukU5aVQxRMUSGrzmve6agawHLgiOUd7zkvS2Axsk--R7iQjbuWT9EBP5lCuWfKfCnFPjnFNQ4lTlGq3EC-pkhczJpf4Zcd3c-X6AlJnmN7MgsdcXf7HvQqh4m9T6R45F7EN-gR_FYDPG0GOKJHtU36PGBQvWUQvVUD_xUD7HqUT3o8bzi_EnFV1lT7dfVw0uhxmm5QtNVZ7WrIwzSBHoPA1adslUdV8K_nJidd36e4vuFWentTp82qIe2d029Miwdc9A-RPA0OR-pB2fhVIqybJp04g_wUgcCHZcerEMKkTC5SDZqacDPNupxxetkWDByf569JxthnkL0JEe4kQ_a2e0HPn_83fQt7_d8LzfUlnWDDcei3G2ubVGgKhqFsq53KJq6qUW_K_d9PRSK14PY6BYL5IXgRVGlmC3nfdFx0e2pqSuxL5koaJTa_Orzm5xCW6Oo9puselgHmW_TppduvgQmCqNDDO9hUUeTR95faXT9eB2nwKoTvDrvSUWbBpYnI1NxowP6-aKuUtuH6RU2szftxxl00fE6d1vlRobndNT98TJ59w-pyPCc6QaG58z4_wAAAP__7pcf6w">