<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/106511>106511</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[InstCombine] Transform sub(select, select) into select when they have same conditions
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:instcombine
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
vfdff
</td>
</tr>
</table>
<pre>
* test: https://alive2.llvm.org/ce/z/An8eOd
```
define i32 @sub_select_select_src(i32 %a) {
%cmp = icmp eq i32 %a, 0
%lhs = select i1 %cmp, i32 1, i32 %a
%rhs = select i1 %cmp, i32 9, i32 %a
%res = sub nsw i32 %lhs, %rhs
ret i32 %res
}
```
* we expect have the result after instCombine transform
```
define i32 @sub_select_select_tgt(i32 %a) {
%cmp = icmp eq i32 %a, 0
%res = select i1 %cmp, i32 -8, i32 0
ret i32 %res
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysU02PnDAM_TXmEu0oOGSGHDiwO0LqqZfeqwBmSBVgmoTZbn99FT5mWmmrqlUlRJz4PSd-trX35jISFSCfQZ4TPYd-csWta7suqaf2rQAsWSAfQJSsD-HqQZSAFWClrbkRHqy9DYfJXQCrhgCr74BVOeb0sQV-Bl7CkW_fsm2pMyMxI5BBxv1cf_ZkqQn3xTWA-eJGqQEVg9PzSmXxqBmuDMSZmWjQV_ZAvjD-E872fsGtYZlJN3LERU66Gwv5wXN_4Kl3eJFGG22u2ehfd4TtfcSvcfdbHIXd72g7hdP5Xbm2P5bslRh9u8Y39fpGLPTEHPnZBqa7QI6Z0YeXaaijusHp0XeTG9g_1SBcwn-pwV2U32j5lO8W_zttkrYQrRJKJ1SkJ8wUYprlSV-I7HSUjZAoTlql7ZF0l2VcZFI2kk75MTEFcsx4joorjpgf0lYqLlVODSlxFBoyToM29t7XifF-piLlR5mmidU1Wb-MC2KEgCij8s2qPCDGMXJFdD3V88VDxq3xwT_iBRPsMnAfHhUDeWaf7kXzcw2Yr6pFhXZLMTOGaZfztacxtsHb2hBeD8SaaWxNMNPok9nZ4teBvZjQz_WhmQbAann7ujxd3fRluaBacvWA1ZburcAfAQAA__9pazCf">