<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 - CVP: adding nuw flags not correct in the presence of undef"
href="https://bugs.llvm.org/show_bug.cgi?id=42618">42618</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>CVP: adding nuw flags not correct in the presence of undef
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</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>nunoplopes@sapo.pt
</td>
</tr>
<tr>
<th>CC</th>
<td>jdoerfert@anl.gov, llvm-bugs@lists.llvm.org, me+llvm@luqman.ca, nikita.ppv@gmail.com, regehr@cs.utah.edu
</td>
</tr></table>
<p>
<div>
<pre>The following unit test shows incorrect behavior regarding undef inputs:
$ opt -correlated-propagation -cvp-dont-add-nowrap-flags=false
Transforms/CorrelatedValuePropagation/sub.ll
The issue is the branch on undef, which if we assume is a non-deterministic
jump, leads to branch %then, which then does a 'sub nuw' on an undef (which is
poison).
Possible solutions: same as in #42617.
define i32 @test11(* %p, i32 %i) {
%limit = load i32, * %p, align 4
%range_l#0%limit = icmp sge i32 %limit, 0
%range_h#0%limit = icmp slt i32 %limit, 2147483647
%range#0%limit = and i1 %range_l#0%limit, %range_h#0%limit
assume_non_poison i1 %range#0%limit
%within.1 = icmp slt i32 %limit, %i
%i.minus.7 = add i32 %i, 4294967289
%within.2 = icmp slt i32 %limit, %i.minus.7
%within = and i1 %within.1, %within.2
br i1 %within, label %then, label %else
%then:
%i.minus.6 = sub i32 %i, 6
ret i32 %i.minus.6
%else:
ret i32 0
}
=>
define i32 @test11(* %p, i32 %i) {
%limit = load i32, * %p, align 4
%range_l#0%limit = icmp sge i32 %limit, 0
%range_h#0%limit = icmp slt i32 %limit, 2147483647
%range#0%limit = and i1 %range_l#0%limit, %range_h#0%limit
assume_non_poison i1 %range#0%limit
%within.1 = icmp slt i32 %limit, %i
%i.minus.7 = add i32 %i, 4294967289
%within.2 = icmp slt i32 %limit, %i.minus.7
%within = and i1 %within.1, %within.2
br i1 %within, label %then, label %else
%then:
%i.minus.6 = sub nsw nuw i32 %i, 6
ret i32 %i.minus.6
%else:
ret i32 0
}
Transformation doesn't verify!
ERROR: Target is more poisonous than source
Example:
* %p = #x2dc920000000
i32 %i = undef
Source:
i32 %limit = #x00000000 (0)
i1 %range_l#0%limit = #x1 (1)
i1 %range_h#0%limit = #x1 (1)
i1 %range#0%limit = #x1 (1)
i1 %within.1 = undef
i32 %i.minus.7 = undef
i1 %within.2 = undef
i1 %within = undef
i32 %i.minus.6 = undef
Target:
i32 %limit = #x00000000 (0)
i1 %range_l#0%limit = #x1 (1)
i1 %range_h#0%limit = #x1 (1)
i1 %range#0%limit = #x1 (1)
i1 %within.1 = undef
i32 %i.minus.7 = undef
i1 %within.2 = undef
i1 %within = undef
i32 %i.minus.6 = poison
Source value: undef
Target value: poison</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>