Skip to content

Commit 1b838a4

Browse files
nickdesaulniersmemfrob
authored and
memfrob
committed
[PPCISelLowering] avoid emitting libcalls to __mulodi4()
Similar to D108842, D108844, and D108926. __has_builtin(builtin_mul_overflow) returns true for 32b PPC targets, but Clang is deferring to compiler RT when encountering long long types. This breaks ppc44x_defconfig + CONFIG_BLK_DEV_NBD=y builds of the Linux kernel that are using builtin_mul_overflow with these types for these targets. If the semantics of __has_builtin mean "the compiler resolves these, always" then we shouldn't conditionally emit a libcall. This will still need to be worked around in the Linux kernel in order to continue to support these builds of the Linux kernel for this target with older releases of clang. Link: https://bugs.llvm.org/show_bug.cgi?id=28629 Link: ClangBuiltLinux/linux#1438 Reviewed By: nemanjai Differential Revision: https://reviews.llvm.org/D108936
1 parent f7668c3 commit 1b838a4

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,7 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine &TM,
13011301
setLibcallName(RTLIB::SHL_I128, nullptr);
13021302
setLibcallName(RTLIB::SRL_I128, nullptr);
13031303
setLibcallName(RTLIB::SRA_I128, nullptr);
1304+
setLibcallName(RTLIB::MULO_I64, nullptr);
13041305
}
13051306

13061307
if (!isPPC64)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; RUN: llc %s -mtriple=powerpc -o - | FileCheck %s
2+
3+
define i1 @no__mulodi4(i32 %a, i64 %b, i32* %c) {
4+
; CHECK-LABEL: no__mulodi4
5+
; CHECK-NOT: bl __mulodi4
6+
entry:
7+
%0 = sext i32 %a to i64
8+
%1 = call { i64, i1 } @llvm.smul.with.overflow.i64(i64 %0, i64 %b)
9+
%2 = extractvalue { i64, i1 } %1, 1
10+
%3 = extractvalue { i64, i1 } %1, 0
11+
%4 = trunc i64 %3 to i32
12+
%5 = sext i32 %4 to i64
13+
%6 = icmp ne i64 %3, %5
14+
%7 = or i1 %2, %6
15+
store i32 %4, i32* %c, align 4
16+
ret i1 %7
17+
}
18+
19+
declare { i64, i1 } @llvm.smul.with.overflow.i64(i64, i64)

0 commit comments

Comments
 (0)