<html>
<head>
<base href="http://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 --- - bitfield load/stores not merged"
href="http://llvm.org/bugs/show_bug.cgi?id=18680">18680</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>bitfield load/stores not merged
</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>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>hfinkel@anl.gov
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=11984" name="attach_11984" title="original IR">attachment 11984</a> <a href="attachment.cgi?id=11984&action=edit" title="original IR">[details]</a></span>
original IR
I noticed, in the context of debugging another problem, that Clang/LLVM
generates what seems like poor code for the bitfield copies in
llvm::APFloat::assign(llvm::APFloat const&):
APFloat::assign(const APFloat &rhs)
{
...
sign = rhs.sign;
category = rhs.category;
...
which generates (at least for ppc64):
%sign = getelementptr inbounds %"class.llvm::APFloat"* %rhs, i64 0, i32 3
%bf.load = load i8* %sign, align 2
%sign3 = getelementptr inbounds %"class.llvm::APFloat"* %this, i64 0, i32 3
%bf.load4 = load i8* %sign3, align 2
%bf.shl = and i8 %bf.load, 16
%bf.clear5 = and i8 %bf.load4, -17
%bf.set = or i8 %bf.clear5, %bf.shl
store i8 %bf.set, i8* %sign3, align 2
%bf.load6 = load i8* %sign, align 2
%bf.lshr7 = and i8 %bf.load6, -32
%bf.clear13 = and i8 %bf.set, 31
%bf.set14 = or i8 %bf.clear13, %bf.lshr7
store i8 %bf.set14, i8* %sign3, align 2
which has an extra load/store pair. We should produce something more like:
%sign = getelementptr inbounds %"class.llvm::APFloat"* %rhs, i64 0, i32 3
%bf.load = load i8* %sign, align 2
%sign3 = getelementptr inbounds %"class.llvm::APFloat"* %this, i64 0, i32 3
%bf.load4 = load i8* %sign3, align 2
%bf.lshr7 = and i8 %bf.load4, -32
%bf.clear13 = and i8 %bf.load, 31
%bf.set14 = or i8 %bf.clear13, %bf.lshr7
store i8 %bf.set14, i8* %sign3, align 2</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>