<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 --- - [Scalar] alignTo is not optimized if alignment is a power of 2"
href="https://llvm.org/bugs/show_bug.cgi?id=31368">31368</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[Scalar] alignTo is not optimized if alignment is a power of 2
</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>normal
</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>davide@freebsd.org
</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>This came up as part of <a href="https://reviews.llvm.org/D27082">https://reviews.llvm.org/D27082</a>
Testcase by Rafael.
uint64_t foo(uint64_t Value, uint64_t Align) {
return alignToNonP2(Value, 1 << Align);
}
but it still produces
define i64 @_Z3foomm(i64 %Value, i64 %Align) local_unnamed_addr #0 {
entry:
%sh_prom = trunc i64 %Align to i32
%shl = shl i32 1, %sh_prom
%conv = sext i32 %shl to i64
%add.i = add i64 %Value, -1
%sub.i = add i64 %add.i, %conv
%div.i = urem i64 %sub.i, %conv
%add2.i = sub i64 %sub.i, %div.i
ret i64 %add2.i
}
Changing 1 to 1ULL does cause us to optimize it
define i64 @_Z3foomm(i64 %Value, i64 %Align) local_unnamed_addr #0 {
entry:
%shl = shl i64 1, %Align
%add.i = add i64 %Value, -1
%sub.i = add i64 %add.i, %shl
%.not = sub i64 0, %shl
%add2.i = and i64 %sub.i, %.not
ret i64 %add2.i
}</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>