<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/115574>115574</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[InstSimplify] wrong folding of pointer comparison `select (icmp eq ptr ...)`
</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>
Alive2 report: https://alive2.llvm.org/ce/z/aux2zY
```llvm
----------------------------------------
define ptr @smin_test8.2(ptr %a, ptr %b, ptr %c) {
#0:
%cmp1 = icmp eq ptr %a, %b
%umin1 = select i1 %cmp1, ptr %a, ptr %b
%cmp2 = icmp slt ptr %b, %c
%umin2 = select i1 %cmp2, ptr %b, ptr %c
%cmp3 = icmp ult ptr %umin2, %a
%umin3 = select i1 %cmp3, ptr %umin2, ptr %a
%cmp4 = icmp slt ptr %c, %umin3
%res = select i1 %cmp4, ptr %umin1, ptr %umin3
ret ptr %res
}
=>
define ptr @smin_test8.2(ptr %a, ptr %b, ptr %c) {
#0:
%cmp2 = icmp slt ptr %b, %c
%umin2 = select i1 %cmp2, ptr %b, ptr %c
%cmp3 = icmp ult ptr %umin2, %a
%umin3 = select i1 %cmp3, ptr %umin2, ptr %a
%cmp4 = icmp slt ptr %c, %umin3
%res = select i1 %cmp4, ptr %b, ptr %umin3
ret ptr %res
}
Transformation doesn't verify!
ERROR: Value mismatch
Example:
ptr %a = pointer(non-local, block_id=0, offset=1) / Address=#x1
ptr %b = pointer(non-local, block_id=1, offset=0) / Address=#x1
ptr %c = pointer(non-local, block_id=0, offset=-8) / Address=#x8
Source:
i1 %cmp1 = #x1 (1)
ptr %umin1 = pointer(non-local, block_id=0, offset=1) / Address=#x1
i1 %cmp2 = #x0 (0)
ptr %umin2 = pointer(non-local, block_id=0, offset=-8) / Address=#x8
i1 %cmp3 = #x0 (0)
ptr %umin3 = pointer(non-local, block_id=0, offset=1) / Address=#x1
i1 %cmp4 = #x1 (1)
ptr %res = pointer(non-local, block_id=0, offset=1) / Address=#x1
SOURCE MEMORY STATE
===================
NON-LOCAL BLOCKS:
Block 0 > size: 0 align: 1 alloc type: 0 alive: false address: 0
Block 1 > size: 1 align: 1 alloc type: 0 alive: true address: 1
Block 2 > size: 1 align: 1 alloc type: 0 alive: true address: 2
Block 3 > size: 3 align: 1 alloc type: 0 alive: true address: 8
Target:
i1 %cmp2 = #x0 (0)
ptr %umin2 = pointer(non-local, block_id=0, offset=-8) / Address=#x8
i1 %cmp3 = #x0 (0)
ptr %umin3 = pointer(non-local, block_id=0, offset=1) / Address=#x1
i1 %cmp4 = #x1 (1)
ptr %res = pointer(non-local, block_id=1, offset=0) / Address=#x1
Source value: pointer(non-local, block_id=0, offset=1) / Address=#x1
Target value: pointer(non-local, block_id=1, offset=0) / Address=#x1
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/eJzsV99v4jgQ_mvMiwXyj5DAQx5oKdLpuovU9k7ap5XjONQ9J87ZDtv2rz_ZBJIgVgs99h5OW0Uljiff941nPPEwa-WmEiIF0xswXY5Y4561STNdbV6a6mWU6fwtXSi5FQQaUWvjAF3AZ-dqC-gCkBUgKxamJ0pty4k2G0BWXACyevdTzSt5_wLQEqBF-z9Gu8ub7x6Nz_zbWeeikJWAtTMQRMiWsvrqhHWzCQFkFp6SKQPkFrb3We-eAzKHILlppRCKvBNhAMN8WWMI6BJKXtZQ_A37eAGrs21KWe2MrVCCOyjxHqLHOFQyYCIdk1VuIDdIHVKRk1Tku44OqGhH1XRUAbalY0d09CQd7VEc3j54ukPYWUYnneMtW2DoMRphT_JFR3z4aHzAMOLAYYRtw5ss2xu6BPTuP8me_2lMLw7qmTHNPhTPJ8MqW2hTMid1BXMtbAVI4uBWGFm8AYL7Befu4WH94IvWn0w1ApbSlszx54HJKytrJQ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