<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/118156>118156</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[InstCombine] Relax one-use constraint for `umin(X + 1, C) - 1 -> umin(X, C - 1)`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:instcombine,
missed-optimization
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
dtcxzyw
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dtcxzyw
</td>
</tr>
</table>
<pre>
Alive2: https://alive2.llvm.org/ce/z/7oycKu
```
----------------------------------------
declare void @use(i32)
define i32 @src1(i32 %a) {
#0:
%inc = add nsw nuw i32 %a, 1
call void @use(i32 %inc)
%min = umin i32 %inc, 16
%spec.select = add nsw i32 %min, 4294967295
ret i32 %spec.select
}
=>
declare void @use(i32)
define i32 @src1(i32 %a) {
#0:
%inc = add nsw nuw i32 %a, 1
tail call void @use(i32 %inc)
%min = umin i32 %inc, 16
%spec.select = add nsw i32 %min, 4294967295
%#range_0_%spec.select = !range i32 %spec.select, i32 0, i32 16
ret i32 %#range_0_%spec.select
}
Transformation seems to be correct!
----------------------------------------
define i32 @src2(i32 %a) {
#0:
%inc = add nsw nuw i32 %a, 1
%min = umin i32 %inc, 16
%spec.select = add nsw i32 %min, 4294967295
ret i32 %spec.select
}
=>
define i32 @src2(i32 %a) nofree willreturn memory(none) {
#0:
%#1 = umin i32 %a, 15
%#range_0_%#1 = !range i32 %#1, i32 0, i32 16
ret i32 %#range_0_%#1
}
Transformation seems to be correct!
Summary:
2 correct transformations
0 incorrect transformations
0 failed-to-prove transformations
0 Alive2 errors
```
We should enable this fold in `%src1` to fix a regression introduced by https://github.com/llvm/llvm-project/pull/116888.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVcGO2zYQ_Rr6MrBBDS3ZOuig9cZA0VtboL0FlDiyWVCkQVLe9X59QVrebDbZNhukiGHYAufNkPPeE0eGoA-WqGHlHUNUsX98ujwwRFbeL-QUj8438-Kic-rStEafCZlo4RjjKTDRMtwz3Mu8vjLmPK6cPzDc98Rw_8Rwv3GX_teJ8ZZVfP7ylvF2-Y0fxltFvZGe4Oy0ArbmUyCGWy2QYX0tpmjQlkALTPHg--IKAIalZFgD29wlJAqezsxbSBFte2DiHqRSYMMD2OkBPiXtoMjAXhrz5dZz_vUEudqoba42pYeXiB0U1Q0UTtSvAhnq42dbz_hR24RfY72uqw3WZc7zFG-AF_mpn819-hX3THz46TxFqc2PI-t7uWJYMhRe2gN95B-_UoVhkaNfYxR3eZXfHmbdXvD_Zu1nNf7w0obB-VFG7SwEojFAdNAR9M77vE1xVeO9b8Er7fDHafd_KvLt7v2P_qwbPBE8aGM8xclbGGl0_sJwa52lNylgKIovWrs2_4ZnnjNemyUF3u2SnPQd9vh9GkfpL7dO8AaA-FmNkKMctP33-CC1IbWMbnny7kxvoK43PJD3zodXt_afBOHoJqOArOwMQTzqAIMzCpJ5Kp4kTndKxVNLg34ECZ4OnkJIzWobvVNTTwq6y6sJctDxOHWr3o0M92mOzH_psH9nVvanyRiG-6Kottvt6srRQjVC1aKWC2qKjcB6vS2xWhyboa5FxUmtRY-yV7IvZad4z7sCyxKHeqEb5LguCsF5JUqsVkU1CLEVG1UOGz6sS7bmNEptnqfaQocwUVMU26KsFkZ2ZMI8OfOBRattiL0bO53ciAx3DHHUIZBaulPUo37KXM8D1je5wW46BLbmRocYPu0VdTR5Lv9iQ9zNNct7-I2MfARnaTmFZBkbopfaRhicTxJM-SXc_gUM7yB7dZdejCUUsGTiA9ziOZKW06Vc8cXkTfNuRTIhIWuSOTk3-E8AAAD__2iqXJM">