[llvm] [TargetLowering] Lower ldexp into target supported instructions (PR #67552)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 7 09:12:55 PDT 2023


================
@@ -57389,3 +57396,40 @@ Align X86TargetLowering::getPrefLoopAlignment(MachineLoop *ML) const {
     return Align(1ULL << ExperimentalPrefInnermostLoopAlignment);
   return TargetLowering::getPrefLoopAlignment();
 }
+
+SDValue X86TargetLowering::LowerFLDEXP(SDValue Op, SelectionDAG &DAG) const {
+  SDValue X = Op.getOperand(0);
+  EVT XScalarTy = X.getValueType();
+  SDValue Exp = Op.getOperand(1);
+
+  SDLoc DL(Op);
+  EVT XVT, ExpVT;
+  SDValue IID;
+  switch (Op.getValueSizeInBits()) {
+  default:
+    return SDValue();
+  case 32:
+    XVT = MVT::v4f32;
+    ExpVT = MVT::v4f32;
+    IID = DAG.getConstant(Intrinsic::x86_avx512_mask_scalef_ss, DL, MVT::i64);
+    break;
+  case 64:
+    XVT = MVT::v2f64;
+    ExpVT = MVT::v2f64;
+    IID = DAG.getConstant(Intrinsic::x86_avx512_mask_scalef_sd, DL, MVT::i64);
+    break;
+  }
+
+  SDValue Zero = DAG.getConstant(0, DL, MVT::i64);
+  Exp = DAG.getNode(ISD::SINT_TO_FP, DL, XScalarTy, Exp);
+  SDValue VX =
+      DAG.getNode(ISD::INSERT_VECTOR_ELT, DL, XVT, DAG.getUNDEF(XVT), X, Zero);
+  SDValue VExp = DAG.getNode(ISD::INSERT_VECTOR_ELT, DL, ExpVT,
----------------
arsenm wrote:

Is this lowering the scalar case as a vector operation? Should this move to the vector legalizer?

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


More information about the llvm-commits mailing list