<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - [InstCombine] failed to convert selects into add"
href="https://llvm.org/bugs/show_bug.cgi?id=30273">30273</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[InstCombine] failed to convert selects into add
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>spatel+llvm@rotateright.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>This example is a simplified test based on actual code in
InstCombineCompares.cpp as of r280624:
$ cat boolcow.c
#include <stdbool.h>
unsigned foo(bool a, bool b) {
unsigned ret = 0;
if (a) ++ret;
if (b) ++ret;
return ret;
}
This is logically equivalent in C99 or C++ to:
unsigned goo(bool a, bool b) {
return a + b;
}
It seems that there's a missing transform in InstCombine itself because the IR
for these two cases is:
$ ./clang -O1 boolcow.c -S -o - -emit-llvm
define i32 @foo(i1 %a, i1 %b) {
%. = zext i1 %a to i32
%inc4 = select i1 %a, i32 2, i32 1
%ret.1 = select i1 %b, i32 %inc4, i32 %.
ret i32 %ret.1
}
define i32 @goo(i1 %a, i1 %b) {
%conv = zext i1 %a to i32
%conv3 = zext i1 %b to i32
%add = add nuw nsw i32 %conv3, %conv
ret i32 %add
}
...so fix this bug, and the compiler might get faster. :)</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>