<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/115456>115456</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[InstCombine] miscompilation
</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>
https://github.com/llvm/llvm-project/blob/6de5305b3d7a4a19a29b35d481a8090e2a6d3a7e/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp#L360-L363
Alive2 report: https://alive2.llvm.org/ce/z/Rq5DNd
```llvm
----------------------------------------
define i32 @test1.2(i32 %b, i32 %z) {
#0:
%c = sub i32 0, %z
%#1 = sdiv i32 %z, %c
%d = mul nsw i32 %#1, %b
%e = mul i32 %c, %d
ret i32 %e
}
=>
define i32 @test1.2(i32 %b, i32 %z) {
#0:
%#1 = icmp eq i32 %z, 2147483648
%#2 = sub nsw i32 0, %b
%#3 = select i1 %#1, i32 %#2, i32 %b
%.neg = mul i32 %#3, %z
ret i32 %.neg
}
Transformation doesn't verify!
ERROR: Target is more poisonous than source
Example:
i32 %b = #x80000000 (2147483648, -2147483648)
i32 %z = #x80000000 (2147483648, -2147483648)
Source:
i32 %c = #x80000000 (2147483648, -2147483648)
i32 %#1 = #x00000001 (1)
i32 %d = #x80000000 (2147483648, -2147483648)
i32 %e = #x00000000 (0)
Target:
i1 %#1 = #x1 (1)
i32 %#2 = poison
i32 %#3 = poison
i32 %.neg = poison
Source value: #x00000000 (0)
Target value: poison
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/eJysVduOozgTfhpzYyWyy5xywUVPZyL90vy7UnZewECRuAWYsU1mup9-ZUNows7saRZFBFPfV4fPZUpaqy49YkGSDyQ5RnJ0V22KUveXl7F_iUpdvxZX5wZLxBOBE4HTRbnrWO4r3RE4te3t_rcbjH7ByhE4la0uCZzSGhPBklLUmYwlP0g4lCKp45zLnB0YgkxrITNc-VGe99nI3jbadJbA6X-9dc-6K1WPj6v_j-1R3c7Y7athICA-iZTtPolUEHYk7Gm6P7XqhkANDto4Ip7oYy0ymPc--l6bC4FT5aO8ETidvyTHX-q1L5Ky6ReSDa92f_Oa0DU2qkeqBFASM4fW8T0QyMMLSEoCz3R-fiNwoCT7MEcGwXzOYUG9vaJEHKkdy0BgnhlY7wgCgk-gWt1WbgOwWgHrgOrGlvb26x3o2TO2XGFxwc64agbVd5BBd7fhnHx2nB_EkYiP_7kUS6Gq6gaKXx5qBR5ncS7SOH9kwKLfvWj2nXIJCDEBscXKUcXX2rxLBavlmr_v8bJVzPvcbtdKNE_Z6LYcB-mU7mmt0fYEMkdvaFTzSoCvu_Tj-fzr2Xf6Z2ku3q-lnTZIB62s7vVoqbvKnlo9mgofiN9kN7S4iHuvJxRAQHzL2XRRAvlKV3imu_Xy8EB_-5f06f7blOUmpernUloaxnuYHfiNzfkWWf9cINxGCXS2qXHap_ca-R9y_H5ySxdPO7u1iR_ZlqZc2yah6U22o5f7T5Ke22pBrr3Mvsauk-Z1dUoZrbQx_gS5h162dwCnqv8LCKONVC3WO6f9pLnhj4HzRx-N0cZuvt1RXYj6IA4ywoJngrOUQ86ja4EVq-NGChZjeciaBJKccy5ZjlnZZCVEqgAGMecs5ww48H2NcZMmVSwxb5oSOYkZdlK1yziJlLUjFpwncZJGrSyxtWHQAvT4lQYrAfBz1xRhhJbjxZKYtco6--7GKdeGCb2ehcmRdspWuhtUGwSIRtP-81EdkvBzds7yVsDvAQAA___0eSIt">