[llvm] [SelectionDAG][RISCV] Operations with static rounding (PR #100999)
Serge Pavlov via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 2 05:30:53 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 &&
----------------
spavloff wrote:
What is wrong with using constrained intrinsic for operations with static rounding?
LangRef defines these intrinsics (https://llvm.org/docs/LangRef.html#constrained-floating-point-intrinsics):
> These intrinsics are used to provide special handling of floating-point operations when specific rounding mode or floating-point exception behavior is required.
This is just what is required for static rounding operations. The bad thing is the side effect, which is present on every constrained intrinsic. It however does not break the semantics of static rounding, it only prevents some optimization.
Constrained intrinsics are used here as per their desigs, no?
https://github.com/llvm/llvm-project/pull/100999
More information about the llvm-commits
mailing list