<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 --- - Flatten two comparisons against a constant power of two into an OR + cmp"
href="https://llvm.org/bugs/show_bug.cgi?id=26430">26430</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Flatten two comparisons against a constant power of two into an OR + cmp
</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>Linux
</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>Common Code Generator Code
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>listmail@philipreames.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>Given an IR fragment like the following:
bb1:
%cmp1 = icmp ult i32 %a, 16
br i1 %cmp1, label %bb2, label %exit1 ;; rarely not taken
bb2:
%cmp2 = icmp ult i32 %b, 16
br i1 %cmp2, label %fallthrough, label %exit2 ;; rarely not taken
fallthrough:
...
We can rewrite this as:
bb1:
%or = or i32 %a, %b
%cmp1 = icmp ult i32 %or, 16
br i1 %cmp1, label %fallthrough, label %common_exit ;; rarely not taken
fallthrough:
...
common_exit:
%cmp2 = icmp ult i32 %a, 16
br i1 %cmp2, label %exit1, label %exit2 ;; rarely not taken
This transform is likely fairly target specific and produces IR which is hard
for other passes to analyse. Given that, it probably belongs fairly late. CGP
might be one reasonable place.
The general conditions under which this will apply are:
- Two successive tests against the same constant on different values
- The tests form what is essentially a bit test. i.e. ult for 2^X or ule for
2^X-1.
- The first branch fails rarely.
- No side effecting instructions in %bb2 and few total instructions (we end up
essentially speculating them)</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>