[llvm] [NVPTX] Lower v1 EX2 intrinsics (PR #223622)

Durgadoss R via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 17 06:21:12 PDT 2026


================
@@ -7610,6 +7610,29 @@ static void ReplaceINTRINSIC_W_CHAIN(SDNode *N, SelectionDAG &DAG,
   }
 }
 
+static void ReplaceINTRINSIC_WO_CHAIN(SDNode *N, SelectionDAG &DAG,
+                                      SmallVectorImpl<SDValue> &Results) {
+  assert(N->getValueType(0) == MVT::v1f32 &&
+         "Custom handling of non-v1f32 intrinsic?");
+
+  switch (N->getConstantOperandVal(0)) {
+  default:
+    return;
+  case Intrinsic::nvvm_ex2_approx:
+  case Intrinsic::nvvm_ex2_approx_ftz:
+    break;
+  }
+
+  SDLoc DL(N);
+  SDValue ScalarOperand =
+      DAG.getExtractVectorElt(DL, MVT::f32, N->getOperand(1), 0);
+  SDValue ScalarResult =
+      DAG.getNode(ISD::INTRINSIC_WO_CHAIN, DL, MVT::f32,
+                  {N->getOperand(0), ScalarOperand}, N->getFlags());
+  Results.push_back(
+      DAG.getNode(ISD::BUILD_VECTOR, DL, MVT::v1f32, ScalarResult));
----------------
durga4github wrote:

Can we move this to line 7623, along with the `case` statements? (or, a separate function and then call it from 7623). 

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


More information about the llvm-commits mailing list