<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/68381>68381</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[LVI][CVP] CVP error deleted the `and` instruction.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
miscompilation,
llvm:optimizations
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
DianQK
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DianQK
</td>
</tr>
</table>
<pre>
I tried this IR:
```llvm
define i32 @foo(i1 %c0, i1 %c1, i8 %v1, i8 %v2) {
start:
br i1 %c0, label %bb0, label %bb1
bb0: ; preds = %bb1, %start
%v2_i32 = zext i8 %v2 to i32
br label %bb1
bb1: ; preds = %bb0, %start
%x = phi i32 [ %v2_i32, %bb0 ], [ undef, %start ]
br i1 %c1, label %bb0, label %bb2
bb2: ; preds = %bb1
%v1_i32 = zext i8 %v1 to i32
%y = or i32 %x, %v1_i32
%z = and i32 %y, 255
ret i32 %z
}
```
`%z = and i32 %y, 255` should not be deleted by CVP.
alive2: https://alive2.llvm.org/ce/z/A9T1PH
godbolt: https://llvm.godbolt.org/z/YEqPjTv83
This issue started with LLVM 15.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVE2PszYQ_jXmMtrIjGMWDhyS0KirbqW0WkXqqcLYCV4RnGKTbvLrKxuSZbPN-0oIxp6vZ54ZprRW71ulcsKXBLHQZfvHbwSR8CIqe1ebLh_uImHkOX8B12klwdXawsufhC0ILQi9vhM6PE1zOgxXUu10q0AzBDKnO2MIpjoGgryiBFcwynGQUy-fpjISzIA8L4dg1pWdu-UEEB1MYzWlUI0_CnF_jqcwvZotgLAlHDslLRBWXM1w5aUh0Zgl4Pg7VMAKuKgPd0MHzvjSJnge54wf5KQPcn4Ek2OtB_L48hPI6CEEBcKLcOJL6FupdtNgQfmNqvgnVOFX2PiQqgk98f_SE9_RQ5Cfg5HphpqQf4x4hwgTw0swLFt5tTx7S-T8atMpd1VdRsTPxd0Y3s_mj8ImFGxt-kZCaxwIBVI1yikJ4gyr7WY2jVU2-qQCMbVzR-snEtcE18P9zE__zHR7gutKEVxfCK4X2Vu8-XVw3xspTOO--wfHUTsG8L5__fLP5v3tlLIphjf_B2prewWh2UrCv9rV8Pq6_R1iPotkzmTGsjJSeZxkCU-eecqiOhccVSoyRMYkL2PJVZbEgglZVpLhfBfpHCmymNKEzucJslklWZVWTMqMiioWksypOpS6uRUaBRx5krI0jsIo2XGfHLStzOGom9Jp0_q9giuCGPYDW5ij0wd9CTo7Lp0u98on0e8tmdNGW2c_8zjtmrCqXrcvfrj5crXdEF74DoHqOtPd2uZqBSShZSt9a3VrXddXPtEs6rsm_0r8Xru6F7PKHMYujJ-nY2feVeUIrkOJluA6VPlfAAAA__-z3HE6">