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: unassignedb...@nondot.org Reporter: yuanrui.zh...@intel.com CC: llvm-bugs@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.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs