<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 - EarlyCSE/computeKnownBits regression - assume of xor i1 true, %val is being removed"
href="https://bugs.llvm.org/show_bug.cgi?id=33470">33470</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>EarlyCSE/computeKnownBits regression - assume of xor i1 true, %val is being removed
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Global Analyses
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>arielb1@mail.tau.ac.il
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>It seems that LLVM trunk's early-cse is spuriously removing calls to
`llvm.assume(xor %val, 1)`. This can prevent further optimizations downstream.
This seems to occur because computeKnownBits sees that because of the assume,
the condition must be true, and therefore `%val` must be false. This is sound
but of course kills the assume. There's an `isEphemeralValueOf` check which is
supposed to prevent this situation, but it is not working.
## Meta
Verified locally on r304178. Verified not to occur on Rust's branch of 4.0.
## STR
--
; RUN: opt -S -early-cse < %s | FileCheck %s
declare i1 @food()
declare void @llvm.assume(i1)
define void @hungry() {
; CHECK-LABEL: @hungry
entry-block:
%0 = call i1 @food()
; CHECK: call void @llvm.assume
%1 = xor i1 %0, true
call void @llvm.assume(i1 %1)
ret void
}
--
## Expected Results
The code should remain as-is - there is nothing to simplify.
## Actual Results
The code is optimized into this assume-less version:
--
; ModuleID = '<stdin>'
source_filename = "<stdin>"
declare i1 @food()
; Function Attrs: nounwind
declare void @llvm.assume(i1) #0
define void @hungry() {
entry-block:
%0 = call i1 @food()
ret void
}
---</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>