<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 - X86InstrInfo::analyzeBranch doesn't preserve undef/kill flags on $eflags"
href="https://bugs.llvm.org/show_bug.cgi?id=38150">38150</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>X86InstrInfo::analyzeBranch doesn't preserve undef/kill flags on $eflags
</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>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>francisvm@yahoo.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=20551" name="attach_20551" title="branchfolding-operands.mir">attachment 20551</a> <a href="attachment.cgi?id=20551&action=edit" title="branchfolding-operands.mir">[details]</a></span>
branchfolding-operands.mir
llc -run-pass branch-folder will transform this:
<span class="quote">> bb.0:
> JE_1 %bb.1, implicit undef $eflags
> JMP_1 %bb.2
> bb.1:
> RET 2, undef $eax
> bb.2:
> RET 0, undef $eax</span >
into
<span class="quote">> bb.0:
> JNE_1 %bb.2, implicit $eflags
> bb.1:
> RET 2, undef $eax
> bb.2:
> RET 0, undef $eax</span >
It drops the undef from the $eflags which causes the machine verifier to
complain.
I tracked this down to:
* when X86InstrInfo::analyzeBranchImpl changes the branch to its opposite
because it only copies the MBB operand
* when BranchFolding::TailMergeBlocks calls removeBranch then insertBranch.
Analyze branch doesn’t keep the eflags operand in the Cond vector returned by
analyze branch, so insertBranch won’t be able to re-insert it with the correct
operands.
Attached MIR test.</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>