[llvm] [RISCV][GISel] Support fptoi and itofp for Zfh. (PR #96707)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 25 21:00:15 PDT 2024


================
@@ -416,16 +416,19 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
     FConstantActions.legalFor({s16});
   FConstantActions.lowerFor({s32, s64});
 
-  getActionDefinitionsBuilder({G_FPTOSI, G_FPTOUI})
-      .legalIf(all(typeInSet(0, {s32, sXLen}), typeIsScalarFPArith(1, ST)))
-      .widenScalarToNextPow2(0)
-      .clampScalar(0, s32, sXLen)
-      .libcall();
+  auto &FPToIActions =
+      getActionDefinitionsBuilder({G_FPTOSI, G_FPTOUI})
+          .legalIf(all(typeInSet(0, {s32, sXLen}), typeIsScalarFPArith(1, ST)));
+  if (ST.hasStdExtZfh())
+    FPToIActions.legalFor({{s32, s16}, {sXLen, s16}});
+  FPToIActions.widenScalarToNextPow2(0).clampScalar(0, s32, sXLen).libcall();
----------------
topperc wrote:

Yes. I'm going to simplify this code in a future patch by folding Zfh into `typeIsScalarFPArith`. I just needed to slog through all of the opcodes and test cases first without posting a giant patch.

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


More information about the llvm-commits mailing list