<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 - Remove impossible branches"
href="https://bugs.llvm.org/show_bug.cgi?id=46962">46962</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Remove impossible branches
</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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Interprocedural Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>david.bolvansky@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>unsigned deadbranches(bool A, bool B)
{
if (A || B) {
if (A && B) {
return foo1();
}
else if (A) {
return foo2();
}
else if (B) {
return foo3();
}
else {
return foo5();
}
}
return foo4();
}
else branch: return foo5(); is dead, but Clang does not remove it.
Clang:
deadbranches(bool, bool): # @deadbranches(bool, bool)
test edi, edi
jne .LBB0_2
test sil, sil
jne .LBB0_2
jmp foo4() # TAILCALL
.LBB0_2:
test dil, dil
je .LBB0_4
test sil, sil
je .LBB0_4
jmp foo1() # TAILCALL
.LBB0_4:
test dil, dil
je .LBB0_5
jmp foo2() # TAILCALL
.LBB0_5:
test sil, sil
je .LBB0_6
jmp foo3() # TAILCALL
.LBB0_6:
jmp foo5() # TAILCALL
GCC:
deadbranches(bool, bool):
test dil, dil
jne .L7
test sil, sil
je .L9
.L5:
jmp foo3()
.L9:
jmp foo4()
.L7:
test sil, sil
je .L4
jmp foo1()
.L4:
test dil, dil
je .L5
jmp foo2()
<a href="https://godbolt.org/z/Es5z1x">https://godbolt.org/z/Es5z1x</a></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>