[PATCH] D112750: [SparcISelLowering] avoid emitting libcalls to __muloti4()

Nick Desaulniers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 28 13:00:42 PDT 2021


nickdesaulniers created this revision.
Herald added subscribers: jrtc27, fedor.sergeev, hiraditya, jyknight.
nickdesaulniers requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This compiler-rt-only symbol isn't available in libgcc.
Similar to D108842 <https://reviews.llvm.org/D108842>, D108844 <https://reviews.llvm.org/D108844>, and D108926 <https://reviews.llvm.org/D108926>.

Fixes: pr/52043


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112750

Files:
  llvm/lib/Target/Sparc/SparcISelLowering.cpp
  llvm/test/CodeGen/SPARC/overflow-intrinsic-optimizations.ll


Index: llvm/test/CodeGen/SPARC/overflow-intrinsic-optimizations.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/SPARC/overflow-intrinsic-optimizations.ll
@@ -0,0 +1,15 @@
+; RUN: llc %s -mtriple=sparc -o - | FileCheck %s
+; RUN: llc %s -mtriple=sparc64 -o - | FileCheck %s
+declare { i128, i1 } @llvm.smul.with.overflow.i128(i128, i128)
+
+define i32 @mul(i128 %a, i128 %b, i128* %r) {
+; CHECK-LABEL: mul
+; CHECK-NOT: call __muloti4
+  %mul4 = tail call { i128, i1 } @llvm.smul.with.overflow.i128(i128 %a, i128 %b)
+  %mul.val = extractvalue { i128, i1 } %mul4, 0
+  %mul.ov = extractvalue { i128, i1 } %mul4, 1
+  %mul.not.ov = xor i1 %mul.ov, true
+  store i128 %mul.val, i128* %r, align 16
+  %conv = zext i1 %mul.not.ov to i32
+  ret i32 %conv
+}
Index: llvm/lib/Target/Sparc/SparcISelLowering.cpp
===================================================================
--- llvm/lib/Target/Sparc/SparcISelLowering.cpp
+++ llvm/lib/Target/Sparc/SparcISelLowering.cpp
@@ -1619,6 +1619,8 @@
     setLibcallName(RTLIB::SRA_I128, nullptr);
   }
 
+  setLibcallName(RTLIB::MULO_I128, nullptr);
+
   if (!Subtarget->isV9()) {
     // SparcV8 does not have FNEGD and FABSD.
     setOperationAction(ISD::FNEG, MVT::f64, Custom);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112750.383135.patch
Type: text/x-patch
Size: 1281 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211028/db19f5a1/attachment.bin>


More information about the llvm-commits mailing list