<html>
<head>
<base href="https://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 --- - [ppc] unnecessary zero extension / clear left instruction"
href="https://llvm.org/bugs/show_bug.cgi?id=31377">31377</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[ppc] unnecessary zero extension / clear left instruction
</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>Backend: PowerPC
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>carrot@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Compile the following code with options -m64 -O2 -mvsx -mcpu=power8
typedef unsigned long long uint64;
void foo(unsigned char* p, uint64* pval) {
uint64 code = *p;
if (code < 128) {
*pval = code;
}
}
LLVM generates:
foo: # @foo
.Lfunc_begin0:
# BB#0: # %entry
lbz 3, 0(3) // A
extsb. 3, 3 // B
bltlr 0
# BB#1: # %if.then
clrldi 3, 3, 56 // C
std 3, 0(4)
blr
Instruction A load a byte from *p and zero extends it, instruction B sign
extends it and set cr accordingly, instruction C clears high bits, the result
should be exactly the result of instruction A.
So if instruction B write the result to a different register, or use cmpli
directly, instruction C can be removed.</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>