<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 - Bitfield optimization opportunity"
href="https://bugs.llvm.org/show_bug.cgi?id=37098">37098</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Bitfield optimization 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>All
</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>matze@braunis.de
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>This program:
typedef struct {
unsigned a : 1;
unsigned b : 1;
unsigned c : 1;
unsigned d : 1;
} S;
unsigned overlap(S a, S b) {
return (
(a.a & b.a) |
(a.b & b.b) |
(a.c & b.c) |
(a.d & b.d)
) != 0;
}
in llvm IR:
define i32 @overlap(i32 %arg, i32 %arg1) {
%tmp = and i32 %arg, 1
%tmp2 = and i32 %tmp, %arg1
%tmp3 = lshr i32 %arg, 1
%tmp4 = lshr i32 %arg1, 1
%tmp5 = and i32 %tmp3, 1
%tmp6 = and i32 %tmp5, %tmp4
%tmp7 = or i32 %tmp6, %tmp2
%tmp8 = lshr i32 %arg, 2
%tmp9 = lshr i32 %arg1, 2
%tmp10 = and i32 %tmp8, 1
%tmp11 = and i32 %tmp10, %tmp9
%tmp12 = or i32 %tmp7, %tmp11
%tmp13 = lshr i32 %arg, 3
%tmp14 = lshr i32 %arg1, 3
%tmp15 = and i32 %tmp13, 1
%tmp16 = and i32 %tmp15, %tmp14
%tmp17 = or i32 %tmp12, %tmp16
ret i32 %tmp17
}
could be optimized to:
define i32 @quux(i32 %arg, i32 %arg1) {
%bits0 = and i32 %arg, 15
%and = and i32 %bits0, %arg1
%cmp = icmp ne i32 %and, 0
%res = zext i1 %cmp to i32
ret i32 %res
}
but llvm cannot figure this out at the moment. Maybe there are some
instcombines missing?</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>