<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - SimplifyCFG sinks instructions too aggressively"
href="https://bugs.llvm.org/show_bug.cgi?id=33084">33084</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>SimplifyCFG sinks instructions too aggressively
</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>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Transformation Utilities
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>efriedma@codeaurora.org
</td>
</tr>
<tr>
<th>CC</th>
<td>james.molloy@arm.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Testcase:
int f(int a, int b, int g(void)) {
int c;
if (g) {
g(); c = (a + 31) & -32;
} else {
c = (b + 62) & -64;
}
return c;
}
Pass this to clang -O2, and you get IR something like this:
define i32 @f(i32 %a, i32 %b, i32 ()* %g) local_unnamed_addr #0 {
entry:
%tobool = icmp eq i32 ()* %g, null
br i1 %tobool, label %if.else, label %if.then
if.then: ; preds = %entry
%call = tail call i32 %g() #1
%add = add nsw i32 %a, 31
br label %if.end
if.else: ; preds = %entry
%add1 = add nsw i32 %b, 62
br label %if.end
if.end: ; preds = %if.else, %if.then
%.sink = phi i32 [ -64, %if.else ], [ -32, %if.then ]
%add1.sink = phi i32 [ %add1, %if.else ], [ %add, %if.then ]
%and2 = and i32 %add1.sink, %.sink
ret i32 %and2
}
Sinking the "and" here might not make sense: we're generating two phi nodes to
remove one "and" instruction.
We started sinking the "and" in r280351.
I'm planning to continue looking into this, but suggestions welcome.</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>