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: unassignedb...@nondot.org
Reporter: llvm-...@redking.me.uk
CC: arthur.j.odw...@gmail.com, llvm-bugs@lists.llvm.org,
san...@playingwithpointers.com,
spatel+l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs