[PATCH] D122090: [PPCISelLowering] Avoid emitting calls to __multi3, __muloti4

Aaron Puchert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 19 16:58:02 PDT 2022


aaronpuchert created this revision.
aaronpuchert added reviewers: craig.topper, nemanjai, nickdesaulniers.
Herald added subscribers: steven.zhang, shchenz, kbarton, hiraditya, kristof.beyls.
Herald added a project: All.
aaronpuchert requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

After D108936 <https://reviews.llvm.org/D108936>, @llvm.smul.with.overflow.i64 was lowered to __multi3
instead of __mulodi4, which also doesn't exist on PowerPC 32-bit, not
even with compiler-rt. Block it as well so that we get inline code.

Just to be on the safe side, we also block __muloti4 as D108842 <https://reviews.llvm.org/D108842> did
for ARM. Though I have no idea if there is legitimate C code that ends
up using this since 32-bit arches have no 128-bit int type.

Fixes #54460.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122090

Files:
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/overflow-intrinsic-optimizations.ll


Index: llvm/test/CodeGen/PowerPC/overflow-intrinsic-optimizations.ll
===================================================================
--- llvm/test/CodeGen/PowerPC/overflow-intrinsic-optimizations.ll
+++ llvm/test/CodeGen/PowerPC/overflow-intrinsic-optimizations.ll
@@ -3,6 +3,7 @@
 define i1 @no__mulodi4(i32 %a, i64 %b, i32* %c) {
 ; CHECK-LABEL: no__mulodi4
 ; CHECK-NOT: bl __mulodi4
+; CHECK-NOT: bl __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/PowerPC/PPCISelLowering.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -1340,7 +1340,9 @@
     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);
   }
 
   if (!isPPC64)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122090.416748.patch
Type: text/x-patch
Size: 1066 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220319/0edc43d7/attachment.bin>


More information about the llvm-commits mailing list