[PATCH] D108926: [MipsISelLowering] avoid emitting libcalls to __multi3

Nick Desaulniers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 30 10:40:12 PDT 2021


nickdesaulniers created this revision.
nickdesaulniers added reviewers: rengolin, craig.topper, atanasyan.
Herald added subscribers: jrtc27, hiraditya, arichardson, sdardis.
nickdesaulniers requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Similar to D108842 <https://reviews.llvm.org/D108842> and D108844 <https://reviews.llvm.org/D108844>.

__has_builtin(builtin_mul_overflow) returns true for 32b MIPS targets,
but Clang is deferring to compiler RT when encountering long long
types. This MIPS malta_defconfig 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 malta_defconfig builds of the Linux kernel for this
target with older releases of clang.

Link: https://bugs.llvm.org/show_bug.cgi?id=28629
Link: https://github.com/ClangBuiltLinux/linux/issues/1438


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108926

Files:
  llvm/lib/Target/Mips/MipsISelLowering.cpp
  llvm/test/CodeGen/Mips/overflow-intrinsic-optimizations.ll


Index: llvm/test/CodeGen/Mips/overflow-intrinsic-optimizations.ll
===================================================================
--- llvm/test/CodeGen/Mips/overflow-intrinsic-optimizations.ll
+++ llvm/test/CodeGen/Mips/overflow-intrinsic-optimizations.ll
@@ -3,6 +3,7 @@
 define i1 @no__mulodi4(i32 %a, i64 %b, i32* %c) {
 ; CHECK-LABEL: no__mulodi4
 ; CHECK-NOT: jal __mulodi4
+; CHECK-NOT: jal __multi3
 entry:
   %0 = sext i32 %a to i64
   %1 = call { i64, i1 } @llvm.smul.with.overflow.i64(i64 %0, i64 %b)
Index: llvm/lib/Target/Mips/MipsISelLowering.cpp
===================================================================
--- llvm/lib/Target/Mips/MipsISelLowering.cpp
+++ llvm/lib/Target/Mips/MipsISelLowering.cpp
@@ -509,6 +509,7 @@
     setLibcallName(RTLIB::SHL_I128, nullptr);
     setLibcallName(RTLIB::SRL_I128, nullptr);
     setLibcallName(RTLIB::SRA_I128, nullptr);
+    setLibcallName(RTLIB::MUL_I128, nullptr);
     setLibcallName(RTLIB::MULO_I64, nullptr);
     setLibcallName(RTLIB::MULO_I128, nullptr);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108926.369488.patch
Type: text/x-patch
Size: 1032 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210830/81a84f59/attachment.bin>


More information about the llvm-commits mailing list