[llvm] [SelectionDAG][RISCV] Operations with static rounding (PR #100999)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 29 11:06:12 PDT 2024


================
@@ -8131,15 +8131,73 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
 void SelectionDAGBuilder::visitConstrainedFPIntrinsic(
     const ConstrainedFPIntrinsic &FPI) {
   SDLoc sdl = getCurSDLoc();
+  const TargetLowering &TLI = DAG.getTargetLoweringInfo();
+  EVT VT = TLI.getValueType(DAG.getDataLayout(), FPI.getType());
+  fp::ExceptionBehavior EB = *FPI.getExceptionBehavior();
+  std::optional<RoundingMode> RM = FPI.getRoundingMode();
+
+  SDNodeFlags Flags;
+  if (EB == fp::ExceptionBehavior::ebIgnore)
+    Flags.setNoFPExcept(true);
+
+  if (auto *FPOp = dyn_cast<FPMathOperator>(&FPI))
+    Flags.copyFMF(*FPOp);
+
+  bool UseStaticRounding = EB == fp::ExceptionBehavior::ebIgnore && RM &&
+                           *RM != RoundingMode::Dynamic &&
----------------
topperc wrote:

Isn't the contract for the constrained intrinsics, that the global rounding mode has already been changed? What do we gain by using the static rounding mode instructions?

If the global rounding mode hasn't already been changed, that means that whoever created the constrained intrinsics needs to know what operations support a static rounding mode in the target.

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


More information about the llvm-commits mailing list