<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 --- - llvm.expect() lowering loses information"
href="http://llvm.org/bugs/show_bug.cgi?id=16425">16425</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>llvm.expect() lowering loses information
</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>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>The lowering of llvm.expect() functionality doesn't understand the idiom that
clang emits for __builtin_expect(a || b, 0) and ends up losing information.
int a(void);
int b(void);
int f() {
if (__builtin_expect(a() || b(), 0))
return 0;
return 42;
}
ends up with no branch information:
define i32 @f() #0 {
entry:
%call = tail call i32 @a() #2
%tobool = icmp eq i32 %call, 0
br i1 %tobool, label %lor.rhs, label %lor.end
lor.rhs: ; preds = %entry
%call1 = tail call i32 @b() #2
%tobool2 = icmp ne i32 %call1, 0
%phitmp = select i1 %tobool2, i32 0, i32 42
br label %lor.end
lor.end: ; preds = %entry, %lor.rhs
%0 = phi i32 [ 0, %entry ], [ %phitmp, %lor.rhs ]
ret i32 %0
}
clang emits the following bitcode:
define i32 @f() #0 {
entry:
%retval = alloca i32, align 4
%call = call i32 @a()
%tobool = icmp ne i32 %call, 0
br i1 %tobool, label %lor.end, label %lor.rhs
lor.rhs: ; preds = %entry
%call1 = call i32 @b()
%tobool2 = icmp ne i32 %call1, 0
br label %lor.end
lor.end: ; preds = %lor.rhs, %entry
%0 = phi i1 [ true, %entry ], [ %tobool2, %lor.rhs ]
%lor.ext = zext i1 %0 to i32
%expval = call i32 @llvm.expect.i32(i32 %lor.ext, i32 0)
%tobool3 = icmp ne i32 %expval, 0
br i1 %tobool3, label %if.then, label %if.end
if.then: ; preds = %lor.end
store i32 0, i32* %retval
br label %return
if.end: ; preds = %lor.end
store i32 42, i32* %retval
br label %return
return: ; preds = %if.end, %if.then
%1 = load i32* %retval
ret i32 %1
}</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>