[llvm-bugs] [Bug 40486] New: CodeGenPrepare::CombineUAddWithOverflow - improve icmp eq/ne matching
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Jan 27 03:42:26 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=40486
Bug ID: 40486
Summary: CodeGenPrepare::CombineUAddWithOverflow - improve icmp
eq/ne matching
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Common Code Generator Code
Assignee: unassignedbugs at nondot.org
Reporter: llvm-dev at redking.me.uk
CC: arthur.j.odwyer at gmail.com, llvm-bugs at lists.llvm.org,
sanjoy at playingwithpointers.com,
spatel+llvm at rotateright.com
Reviewing the addcarry cases from [Bug #31754 Comment #3]:
https://godbolt.org/z/eZWlsG
The IR demonstrates that much of the problem is that while
CombineUAddWithOverflow can match the ult/ugt cases of the add result, it can't
handle ult/ugt canonicalizations (against 1/-1/signbit/etc) that result in a
icmp eq/ne instead:
define void @_Z4testILy1EEvRyS0_(i64*, i64*) {
%3 = load i64, i64* %0, align 8
%4 = add i64 %3, 1
store i64 %4, i64* %0, align 8
%5 = icmp eq i64 %4, 0 // <---- fails to match uaddo
%6 = zext i1 %5 to i8
%7 = load i64, i64* %1, align 8
%8 = tail call { i8, i64 } @llvm.x86.addcarry.64(i8 %6, i64 %7, i64 0) #2
%9 = extractvalue { i8, i64 } %8, 1
store i64 %9, i64* %1, align 8
ret void
}
define void @_Z4testILy2EEvRyS0_(i64*, i64*) {
%3 = load i64, i64* %0, align 8
%4 = add i64 %3, 2
store i64 %4, i64* %0, align 8
%5 = icmp ult i64 %4, 2 // <---- matches uaddo
%6 = zext i1 %5 to i8
%7 = load i64, i64* %1, align 8
%8 = tail call { i8, i64 } @llvm.x86.addcarry.64(i8 %6, i64 %7, i64 0) #2
%9 = extractvalue { i8, i64 } %8, 1
store i64 %9, i64* %1, align 8
ret void
}
declare { i8, i64 } @llvm.x86.addcarry.64(i8, i64, i64)
--
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/20190127/5a1db7de/attachment.html>
More information about the llvm-bugs
mailing list