<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 - Better block placement - avoid jmp at entry block"
href="https://bugs.llvm.org/show_bug.cgi?id=44596">44596</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Better block placement - avoid jmp at entry block
</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>Backend: X86
</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>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
</td>
</tr></table>
<p>
<div>
<pre>Function:
<a href="https://github.com/microsoft/test-suite/blob/master/MultiSource/Benchmarks/mediabench/g721/g721encode/g711.c#L149">https://github.com/microsoft/test-suite/blob/master/MultiSource/Benchmarks/mediabench/g721/g721encode/g711.c#L149</a>
Current ASM: <a href="https://godbolt.org/z/qYf5tP">https://godbolt.org/z/qYf5tP</a>
alaw2linear(unsigned char):
mov eax, edi
xor al, 85
movzx eax, al
mov ecx, eax
shl ecx, 4
movzx ecx, cl
shr eax, 4
and eax, 7
cmp eax, 1
je .LBB0_3
test eax, eax
jne .LBB0_4
or ecx, 8
jmp .LBB0_5
.LBB0_3:
or ecx, 264
jmp .LBB0_5
.LBB0_4:
or ecx, 264
dec al
shlx ecx, ecx, eax
.LBB0_5:
mov eax, ecx
neg eax
test dil, dil
cmovs eax, ecx
ret
Better block placement for standard codegen?:
alaw2linear(unsigned char): # @alaw2linear(unsigned char)
mov eax, edi
xor al, 85
movzx eax, al
mov ecx, eax
shl ecx, 4
movzx ecx, cl
shr eax, 4
and eax, 7
cmp eax, 1
je .LBB0_3
test eax, eax
jne .LBB0_4
or ecx, 8
.LBB0_5:
mov eax, ecx
neg eax
test dil, dil
cmovs eax, ecx
ret
.LBB0_3:
or ecx, 264
jmp .LBB0_5
.LBB0_4:
or ecx, 264
dec al
shlx ecx, ecx, eax
jmp .LBB0_5
For this specific case, we have an cmov opportunity too - GCC produces:
alaw2linear(unsigned char):
xor edi, 85
mov ecx, edi
sal ecx, 4
mov edx, edi
and ecx, 240
shr dl, 4
lea eax, [rcx+8]
and edx, 7
je .L5
lea eax, [rcx+264]
movzx ecx, dl
mov esi, eax
dec ecx
cmp dl, 1
shlx eax, eax, ecx
cmove eax, esi
.L5:
mov edx, eax
neg edx
test dil, dil
cmovns eax, edx
ret</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>