[llvm-bugs] [Bug 42618] New: CVP: adding nuw flags not correct in the presence of undef
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Jul 14 08:07:45 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=42618
Bug ID: 42618
Summary: CVP: adding nuw flags not correct in the presence of
undef
Product: libraries
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: nunoplopes at sapo.pt
CC: jdoerfert at anl.gov, llvm-bugs at lists.llvm.org,
me+llvm at luqman.ca, nikita.ppv at gmail.com,
regehr at cs.utah.edu
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
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190714/6a698642/attachment-0001.html>
More information about the llvm-bugs
mailing list