<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/114752>114752</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[InstCombine] an element is overwritten as a `poison`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
bongjunj
</td>
</tr>
</table>
<pre>
The optimizer overwrites the second element of the second operand of `add` as `poison` for no reason.
Alive2 report: https://alive2.llvm.org/ce/z/qka3d8
```llvm
----------------------------------------
define <4 x i8> @sel_shuf_commute3.2(<4 x i8> %x, <4 x i8> %y, i1 %cmp) {
#0:
%#1 = add <4 x i8> %x, { 0, 1, 2, 3 }
%blend = shufflevector <4 x i8> %#1, <4 x i8> %y, 0, 5, 2, 3
%r = select i1 %cmp, <4 x i8> %y, <4 x i8> %blend
ret <4 x i8> %r
}
=>
define <4 x i8> @sel_shuf_commute3.2(<4 x i8> %x, <4 x i8> %y, i1 %cmp) {
#0:
%#1 = add <4 x i8> %x, { 0, poison, 2, 3 }
%sel = select i1 %cmp, <4 x i8> %y, <4 x i8> %#1
%r = shufflevector <4 x i8> %sel, <4 x i8> %y, 0, 5, 2, 3
ret <4 x i8> %r
}
Transformation doesn't verify!
ERROR: Target's return value is more undefined
Example:
<4 x i8> %x = < #x03 (3), #x00 (0) [based on undef value], #x00 (0), #x00 (0) >
<4 x i8> %y = < undef, #x00 (0), #x03 (3), #x00 (0) >
i1 %cmp = undef
Source:
<4 x i8> %#1 = < #x03 (3), #x01 (1), #x02 (2), #x03 (3) >
<4 x i8> %blend = < #x03 (3), #x00 (0), #x02 (2), #x03 (3) >
<4 x i8> %r = < #x03 (3) [based on undef value], #x00 (0), #x02 (2), #x03 (3) >
Target:
<4 x i8> %#1 = < #x03 (3), poison, #x02 (2), #x03 (3) >
<4 x i8> %sel = < #x54 (84), #x00 (0), #x03 (3), #x00 (0) >
<4 x i8> %r = < #x54 (84), #x00 (0), #x02 (2), #x03 (3) >
Source value: < #x03 (3), #x00 (0), #x02 (2), #x03 (3) >
Target value: < #x54 (84), #x00 (0), #x02 (2), #x03 (3) >
Summary:
0 correct transformations
1 incorrect transformations
0 failed-to-prove transformations
0 Alive2 errors
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVktv4zYQ_jXjyyAGRUqWdNDBiddATwXS3BeUNLKZSqRLUt5kf31Byc947XqzLRoEeoyG3zy-If1J59RKExWQPEKymMjer40tSqNXr71-nZSmfi9e1oRm41WnvpNFsyX7zSpPDv2a0FFldI3UUkfao2lOrWZDVoZ7gzBjsq5hxlC68LIxyhkd3htjURu0JJ3RU2ALYPPxOm_Vljha2hjrQcxx7f3GgZgDXwJfyuHztG233dTYFfBlRcCX34Ev__pTijo7xYIZG_-D-2h6uPNv9K6pUZoQxFOMb6gyEF8QYuao_erWffO1Ml3XexJTDjw79-LJG_An_Gh8D0YVhceq2wDPEdLHXbZcsFDn8BIcgIsIQSxQ1vUF0IiePiILD1G48HARCOlihxH8ypZ0PaCEjJuWtlR5Yy_wQrCrCQ8xkmOME3w7YlNLlT8t7ArSR-OQ3h7Okr9wsLvm7IsCsQDx5X-n5yf52U3-NZIctb_WxoG9C1JuEu6o_Wm-7yHoxUrtGmM76ZXRWBtyGnjqcUtWNe_Ao9Mt-uX5-ffnsM1fpF2RB566EKW3Grey7QmVw85Ywl6PbNdnq99kt2npQMsFCUMfQDwhcPHGBALPBPB8KDxYWLCwYGE5JI-ldFSj0WO0MQNIFj9wv7DgYSovOnpIYkC9AXYjvyP8YTgG2BHypCV_mN5W1ztymNkbTQkBsujUwoOF_zDV63UfT567CPilWPZanE_Sel8S47yPg_vJhh8Phs8Xvz899hGSOKzJ4tt9vmvYbvf5vkB31TSO7Y4aMf8PRmbk6TLCv1jErpS-66R9P_mtYFgZa8PJ7s8OR7d3iFDpf3Bh2EjVUv3gzcPGmi1dd9xJKLLWWPdBCU3qQt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