================
@@ -549,6 +562,22 @@ static bool interp__builtin_fpclassify(InterpState &S, 
CodePtr OpPC,
   return true;
 }
 
+static bool interp__builtin_fma(InterpState &S, CodePtr OpPC,
+                                const InterpFrame *Frame, const Function *Func,
+                                const CallExpr *Call) {
+  const Floating &X = getParam<Floating>(Frame, 0);
+  const Floating &Y = getParam<Floating>(Frame, 1);
+  const Floating &Z = getParam<Floating>(Frame, 2);
+  Floating Result;
+
+  llvm::RoundingMode RM = getActiveRoundingMode(S, Call);
----------------
andykaylor wrote:

I have questions about the rounding mode. Is getActiveRoundingMode() trying to 
account for the FE_ROUND pragma setting? If that pragma isn't used and we 
aren't compiling in strict mode, this should give us "NearestTiesToEven", right?

But if the rounding mode is dynamic, then I think we need to know if the call 
is in a constexpr. Consider:

```
float f1() {
  fesetround(FE_UPWARD);
  constrexpr float x = __builtin_fma(1.0f, 0.0f, 0.1f); // constexpr evaluates 
at the default rounding mode?
  float y = __builtin_fma(1.0f, 0.1f, 0.1f); // Non-constexpr should use the 
dynamic rounding mode?
  return x - y;
}
```
I'm not 100% certain about the language rules here, but at least in C my 
understanding is that initialization of non-static, non-constexp expressions 
should be done "as if" evaluated at runtime.

https://github.com/llvm/llvm-project/pull/113020
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to