[llvm] [llvm][CodeGen] Intrinsic `llvm.powi.*` code gen for vector arguments (PR #118242)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 3 16:03:03 PST 2024


================
@@ -4648,6 +4648,24 @@ void SelectionDAGLegalize::ConvertNodeToLibcall(SDNode *Node) {
     bool ExponentHasSizeOfInt =
         DAG.getLibInfo().getIntSize() ==
         Node->getOperand(1 + Offset).getValueType().getSizeInBits();
+    if (!ExponentHasSizeOfInt) {
+      // In some backends, such as RISCV64 and LoongArch64, the i32 type is
+      // illegal and is promoted by previous process. For such cases, the
+      // exponent actually matches with sizeof(int) and a libcall should be
+      // generated.
+      SDNode *ExponentNode = Node->getOperand(1 + Offset).getNode();
+      unsigned LibIntSize = DAG.getLibInfo().getIntSize();
+      if (ExponentNode->getOpcode() == ISD::SIGN_EXTEND_INREG ||
+          ExponentNode->getOpcode() == ISD::AssertSext ||
+          ExponentNode->getOpcode() == ISD::AssertZext) {
+        EVT InnerType = cast<VTSDNode>(ExponentNode->getOperand(1))->getVT();
+        ExponentHasSizeOfInt = LibIntSize == InnerType.getSizeInBits();
+      } else if (ISD::isExtOpcode(ExponentNode->getOpcode())) {
+        ExponentHasSizeOfInt =
+            LibIntSize ==
+            ExponentNode->getOperand(0).getValueType().getSizeInBits();
+      }
----------------
arsenm wrote:

This code should not be trying to look through extensions (nor SIGN_EXTEND_INREG, or the Asserts*. These aren't really extensions).

I'd expect this to just insert the sext to match the libcall integer type

https://github.com/llvm/llvm-project/pull/118242


More information about the llvm-commits mailing list