<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 - Missed conditional tail call opportunity"
href="https://bugs.llvm.org/show_bug.cgi?id=50125">50125</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Missed conditional tail call opportunity
</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>Common Code Generator Code
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>hans@chromium.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Based on an example from
<a href="https://blog.reverberate.org/2021/04/21/musttail-efficient-interpreters.html">https://blog.reverberate.org/2021/04/21/musttail-efficient-interpreters.html</a>
(<a href="https://godbolt.org/z/4afYjjPro">https://godbolt.org/z/4afYjjPro</a>)
$ cat /tmp/a.c
void *fallback(unsigned char *data);
void *stuff(unsigned char *data);
void *foo(unsigned char *data)
{
if (*data & 0x1) {
return fallback(data);
}
data++;
return stuff(data);
}
$ clang -target x86_64-unknown-linux-gnu -Os -S -o - /tmp/a.c
.text
.file "a.c"
.globl foo # -- Begin function foo
.type foo,@function
foo: # @foo
.cfi_startproc
# %bb.0: # %entry
testb $1, (%rdi)
jne .LBB0_1
# %bb.2: # %if.end
incq %rdi
jmp stuff # TAILCALL
.LBB0_1: # %if.then
jmp fallback # TAILCALL
.Lfunc_end0:
.size foo, .Lfunc_end0-foo
.cfi_endproc
Instead of:
jne .LBB0_1
.LBB0_1:
jmp fallback
It could just do:
jne .LBB0_1
The code in BranchFolding.cpp is supposed to do this:
<a href="https://github.com/llvm/llvm-project/blob/e439a463a30833f1c7d366ed722f0f12d1682638/llvm/lib/CodeGen/BranchFolding.cpp#L1520">https://github.com/llvm/llvm-project/blob/e439a463a30833f1c7d366ed722f0f12d1682638/llvm/lib/CodeGen/BranchFolding.cpp#L1520</a>
But it's not firing here.</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>