[llvm-bugs] [Bug 25986] New: The add instruction is incorrectly folded into icmp when there is an overflow by instcombine
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Dec 31 17:07:35 PST 2015
https://llvm.org/bugs/show_bug.cgi?id=25986
Bug ID: 25986
Summary: The add instruction is incorrectly folded into icmp
when there is an overflow by instcombine
Product: new-bugs
Version: 3.7
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: yuanrui.zhang at intel.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
Given the following reduced test:
define i32 @f(i32 %j) {
entry:
%inc = add nsw i32 %j, 1
%cmp = icmp sgt i32 %inc, 0
%conv = zext i1 %cmp to i32
ret i32 %conv
}
define i32 @main() {
entry:
%call = call i32 @f(i32 2147483647)
ret i32 0
}
InstCombine folds the following 2 instructions
%inc = add nsw i32 %j, 1
%cmp = icmp sgt i32 %inc, 0
into:
<badref> = icmp sgt i32 %j, -1
and the IR becomes wrong after InstCombine as below:
define i32 @f(i32 %j) {
entry:
%j.lobit = lshr i32 %j, 31
%j.lobit.not = xor i32 %j.lobit, 1
ret i32 %j.lobit.not
}
define i32 @main() {
entry:
%call = call i32 @f(i32 2147483647)
ret i32 0
}
The error comes from visitICmpInst
--
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/20160101/5dc39689/attachment.html>
More information about the llvm-bugs
mailing list