[llvm-bugs] [Bug 40846] New: Missing redundancy elimination for uadd.with.overflow and manual overflow check
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Feb 24 10:18:12 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=40846
Bug ID: 40846
Summary: Missing redundancy elimination for uadd.with.overflow
and manual overflow check
Product: libraries
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: nikita.ppv at gmail.com
CC: llvm-bugs at lists.llvm.org
Originally reported at: https://github.com/rust-lang/rust/issues/58692
The following IR remains unchanged under opt -O3:
define i1 @test(i64 %x, i64 %y) nounwind {
%a = call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %x, i64 %y)
%b = extractvalue { i64, i1 } %a, 1
br i1 %b, label %trap, label %bb
bb:
%c = extractvalue { i64, i1 } %a, 0
%d = icmp ult i64 %c, %x
ret i1 %d
trap:
call void @llvm.trap()
unreachable
}
declare { i64, i1 } @llvm.uadd.with.overflow.i64(i64, i64)
declare void @llvm.trap()
Here %d is the same as %b, and must be false in %bb by implication.
I think this should be fairly easy to fix (at least for this specific case)
with an instcombine pattern that converts the icmp into an extract, and CSE/GVN
will take care of the rest.
--
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/20190224/800f99c2/attachment.html>
More information about the llvm-bugs
mailing list