<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/112068>112068</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[InstCombine] `noundef` attribute should be dropped after setting `is_zero_poison` to true
</td>
</tr>
<tr>
<th>Labels</th>
<td>
miscompilation,
llvm:instcombine
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
dtcxzyw
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dtcxzyw
</td>
</tr>
</table>
<pre>
Reproducer: https://alive2.llvm.org/ce/z/7-TgAf
```
define i32 @src(i32 %x, i32 %y) {
entry:
%cttz = call noundef i32 @llvm.cttz.i32(i32 %y, i1 false)
%res = lshr i32 %x, %cttz
ret i32 %res
}
define i32 @tgt(i32 %x, i32 %y) {
entry:
%cttz = call noundef i32 @llvm.cttz.i32(i32 %y, i1 true)
%res = lshr i32 %x, %cttz
ret i32 %res
}
define i32 @src2(i32 %x) {
%ct = call noundef i32 @llvm.ctlz.i32(i32 %x, i1 false)
%cmp = icmp ne i32 %x, 0
%res = select i1 %cmp, i32 %ct, i32 123
ret i32 %res
}
define i32 @tgt2(i32 %x) {
%ct = call noundef i32 @llvm.ctlz.i32(i32 %x, i1 true)
%cmp = icmp ne i32 %x, 0
%res = select i1 %cmp, i32 %ct, i32 123
ret i32 %res
}
```
`noundef` attribute should be dropped. Otherwise we will convert a poison value to immediate UB.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzElEGL2zoQxz-NfBEbrFFsJwcfshsM7_Tg8XpeZGkcq8iWkcbJJp--2HG62XZLC6VdCEgT6T8zvxl5VIz20COWLHtkAIb0y-V8YgAs2ydqpNaHcvkzqb05l__hELwZNQYmd7wlGiKTOwYVg0o5e0RYOXfsVj4cGFQaGVQXBlXx8P9h17B0z9Idy9PlN5sGG9sjtxI4W6cxaAab2YDshcETX_ZnBlvOiserCHsK5ynwbPHpgia6cCb3XCvneO_H3mBzczvnNN1YWQmvAc5zAMEb5SIy2N65Cxhnby62gd_ns4S6XQ1It-OAcSEs9svmHUI60AcQUhj_FmAMGt4Q3lEtHD-jcN9QvPy4T7obZm922tySWBTpO7gRHWqanF3Fdw3QdDMEyN_p75_C_76JH0v_9kNmebrgsDzliijYeiTksfWjM7xGboIfBjQr_i-1GE42Ij8hP1nnuPb9EQNxxQdvo-_5UbkROXluuw6NVYT80-PqGikxpTRbuVUJlqKATZGmWymStpQql5gVojAqbWrciK2ptcK8xgZkvikSW0IKa5GKaQEhVk1uso0RmcjNWm4ywdYpdsq6r1MssTGOWAoBab5JnKrRxWVadjZq3w3WKbK-n4YmPDGAScnkzvaRtO9q2-MyT0M5HT3U4yFOvbaR4msYsuTmMfxPH-lp0WV7_stV5aohDDwike0Pk87G5wsG_3yt6CQnP7-hZAyufDu7D5basV5p3zGoZoLr8jAE_xmnt1HNhYgMqqUWxxK-BAAA__8-TMfa">