<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 - [PPC] wrong code generated for cr operations and conditional branch"
href="https://bugs.llvm.org/show_bug.cgi?id=47707">47707</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[PPC] wrong code generated for cr operations and conditional branch
</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>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, nemanja.i.ibm@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>Compile following code with
llc -O2 log3.ll
target datalayout = "e-m:e-i64:64-n32:64"
target triple = "powerpc64le-grtev4-linux-gnu"
define void @foo(i64* %p1, i64 %v1, i8 %v2, i64 %v3) {
store i64 0, i64* %p1, align 8
%ext = zext i8 %v2 to i64
%shift = shl nuw i64 %v1, 8
%merge = or i64 %shift, %ext
%not0 = icmp ne i64 %merge, 0
%bit0 = and i64 %ext, 1 // and & icmp instructions can be
combined
%cond1 = icmp eq i64 %bit0, 0 // to and. and generates condition
code to
br i1 %cond1, label %bb2, label %bb1 // be used by this conditional branch
bb1:
store i64 %v1, i64* %p1, align 8
br label %bb2
bb2:
br i1 %not0, label %exit, label %bb3
bb3:
store i64 %v3, i64* %p1, align 8
br label %exit
exit:
ret void
}
LLVM generates
foo: # @foo
.Lfunc_begin0:
.cfi_startproc
# %bb.0:
andi. 7, 5, 1 // and. sets cr0
rldimi. 5, 4, 8, 0 // rldimi. sets cr0 again
mcrf 1, 0
li 5, 0
std 5, 0(3)
crnot 20, 6
bc 4, 1, .LBB0_2 // bc uses cr0 from rldimi., but it should
use cr0 from and.
# %bb.1: # %bb1
std 4, 0(3)
.LBB0_2: # %bb2
bclr 12, 20, 0
# %bb.3: # %bb3
std 6, 0(3)
blr</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>