<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/96765>96765</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
trunc nuw x to i1 as branch/select cond implies x
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
sftlbcn
</td>
</tr>
</table>
<pre>
https://alive2.llvm.org/ce/z/grTNkc
```
----------------------------------------
define i32 @src(i32 %x, i32 %y) {
#0:
%trunc = trunc nuw i32 %x to i1
%ret = select i1 %trunc, i32 %x, i32 %y
ret i32 %ret
}
=>
define i32 @tgt(i32 %x, i32 %y) {
#0:
%trunc = trunc nuw i32 %x to i1
%ret = select i1 %trunc, i32 1, i32 %y
ret i32 %ret
}
Transformation seems to be correct!
```
```
----------------------------------------
declare void @f()
define i32 @src2(i32 %x, i32 %y) {
bb1:
%cond = trunc nuw i32 %x to i1
br i1 %cond, label %bb2, label %bb3
bb2:
call void @f()
br label %bb3
bb3:
%ret = phi i32 [ %y, %bb2 ], [ %x, %bb1 ]
ret i32 %ret
}
=>
declare void @f()
define i32 @tgt2(i32 %x, i32 %y) {
bb1:
%cond = trunc nuw i32 %x to i1
br i1 %cond, label %bb2, label %bb3
bb2:
call void @f()
br label %bb3
bb3:
%ret = phi i32 [ %y, %bb2 ], [ 0, %bb1 ]
ret i32 %ret
}
Transformation seems to be correct!
Summary:
2 correct transformations
0 incorrect transformations
0 failed-to-prove transformations
0 Alive2 errors
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsVU1v4jwQ_jWTiwVKJiEfhxza8ub4XrZ_wHYm4F0nQbZD6f76VYxpgW21UGlvi5DweD6eZz7wcGvVZiCqYfUIq3XEJ7cdTW07p4UcIjG2r_XWuZ2F9AGwAWy4VnvCpdb7fjmaDWAjCbD5CdhszPP_PyTEa4gfII_D14uLGz9H65Y6NRBTKTLIYmskYOkFXB0An1g4vwJWDIrHgIhpPLP0Apv1zkyDZJCu2fE0TC8n1wNzI1NJMAZcGXLe0pIm6ZhK3gKcAV6CB6DZM9wZcoFLsQ6HdA3pfx9l5TbuL2d1W1rJ3Tk9Gz7YbjQ9d2ocmCXq7QwsiMnRGJIOMHD4cBauxS8NiNTcENuPqp2L2QGWgNV5wN9mCG8ptxDJZbXlOLQ3FVuYUN3ZY46vuSA9XwiBV3J6TnRWv0NKrvXHaXmIz4Okl7xPjd9t1ZHw6jFk-xQ4MVitvXTUHN40idfcP913tsRt3L-WfN6S-Av9uPuf-W3qe25ez3jiyZK5i2D2ZBAzNfzRpONKU7tw42Jnxj19bvjgtwkjY0Zjr56HqK3TtkorHlGdFEmVxRUmRbStqy5NOlGUoqSE2rbLBEfMqcy6QlCXF5GqMcYszjFP0ixO8mXRlqUUWUF5UbZFlUEWU8-VfltjkbJ2orrKi3wV-Y5avxIRB3phXgmI84Y09eyzENPGQhZrZZ19j-KU01S_z2UYSMYtE4YPcgvYhKfYT7Hqd1qRZYdoMvpq0W6U205iKccesJkRws9c0u--lY3nZQGbI-99jb8CAAD__60YGvE">