<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 - Remove 'zero shift' guards from rotation patterns"
href="https://bugs.llvm.org/show_bug.cgi?id=34924">34924</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Remove 'zero shift' guards from rotation patterns
</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>Windows NT
</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>Common Code Generator Code
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>llvm-dev@redking.me.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>davide@freebsd.org, efriedma@codeaurora.org, llvm-bugs@lists.llvm.org, spatel+llvm@rotateright.com
</td>
</tr></table>
<p>
<div>
<pre>For rotation patterns we often have code that prevents out of bounds shifts.
Once we have created rotations its no longer necessary for these guards and
they should be removed to prevent pointless branches.
unsigned rotl(unsigned a, unsigned b) {
return (b == 0 ? a : ((a >> (32-b)) | (a << b)));
}
unsigned rotr(unsigned a, unsigned b) {
return (b == 0 ? a : ((a << (32-b)) | (a >> b)));
}
define i32 @rotl(i32, i32) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %9, label %4
; <label>:4: ; preds = %2
%5 = sub i32 32, %1
%6 = lshr i32 %0, %5
%7 = shl i32 %0, %1
%8 = or i32 %6, %7
br label %9
; <label>:9: ; preds = %2, %4
%10 = phi i32 [ %8, %4 ], [ %0, %2 ]
ret i32 %10
}
define i32 @rotr(i32, i32) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %9, label %4
; <label>:4: ; preds = %2
%5 = sub i32 32, %1
%6 = shl i32 %0, %5
%7 = lshr i32 %0, %1
%8 = or i32 %6, %7
br label %9
; <label>:9: ; preds = %2, %4
%10 = phi i32 [ %8, %4 ], [ %0, %2 ]
ret i32 %10
}
llc -mtriple=x86_64-unknown -mcpu=btver2
rotl:
testl %esi, %esi
je .LBB0_2
movl %esi, %ecx
roll %cl, %edi
.LBB0_2:
movl %edi, %eax
retq
rotr:
testl %esi, %esi
je .LBB1_2
movl %esi, %ecx
rorl %cl, %edi
.LBB1_2:
movl %edi, %eax
retq</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>