<html>
<head>
<base href="http://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 --- - Agressively merge BBs of predict-taken paths"
href="http://llvm.org/bugs/show_bug.cgi?id=16426">16426</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Agressively merge BBs of predict-taken paths
</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>nunoplopes@sapo.pt
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>I think LLVM should be more agressive in merging BBs of predict-taken paths.
E.g.:
size_t safe_address(size_t nmemb, size_t size, size_t offset) {
unsigned long res;
if (__builtin_expect(
__builtin_expect(__builtin_umul_overflow(nmemb, size, &res), 0) ||
__builtin_expect( __builtin_uadd_overflow(res, offset, &res), 0), 0)) {
return 0;
}
return res;
}
(multiple __builtin_expect because of another unrelated bug).
This code compiles to:
define i32 @safe_address(i32 %nmemb, i32 %size, i32 %offset) {
entry:
%0 = tail call { i32, i1 } @llvm.umul.with.overflow.i32(i32 %nmemb, i32
%size)
%1 = extractvalue { i32, i1 } %0, 1
br i1 %1, label %lor.end, label %lor.rhs, !prof !0
lor.rhs: ; preds = %entry
%2 = extractvalue { i32, i1 } %0, 0
%3 = tail call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %2, i32 %offset)
%4 = extractvalue { i32, i1 } %3, 1
%5 = extractvalue { i32, i1 } %3, 0
%phitmp = select i1 %4, i32 0, i32 %5
br label %lor.end
lor.end: ; preds = %lor.rhs, %entry
%6 = phi i32 [ 0, %entry ], [ %phitmp, %lor.rhs ]
ret i32 %6
}
!0 = metadata !{metadata !"branch_weights", i32 4, i32 64}
declare { i32, i1 } @llvm.umul.with.overflow.i32(i32, i32) #1
declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32) #1
attributes #1 = { nounwind readnone }
Since we know that the branch to 'lor.rhs' is assumed to be taken and that
there's no instruction with side-effects in that BB, we should merge the
'entry' and 'lor.rhs' BBs. Merging BBs helps later passes, like instruction
selection.</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>