[llvm] [llubi] Initial support for floating-point numbers (PR #188453)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 9 11:07:40 PDT 2026
================
@@ -108,6 +209,28 @@ class InstExecutor : public InstVisitor<InstExecutor, void>,
});
}
+ void visitFPUnOp(Instruction &I,
+ function_ref<APFloat(const APFloat &)> ScalarFn) {
+ FastMathFlags FMF = cast<FPMathOperator>(I).getFastMathFlags();
+
+ visitUnOp(I, [&](const AnyValue &Operand) -> AnyValue {
+ if (Operand.isPoison())
+ return AnyValue::poison();
+
+ // We don't flush denormals here since the only floating-point unary
+ // operation is fneg. And fneg is specified as a bitwise operation which
+ // only flips the sign bit of the input.
+
+ AnyValue ValidatedOperand = handleFMFFlags(Operand, FMF, true);
+ if (ValidatedOperand.isPoison())
+ return ValidatedOperand;
+
+ APFloat Result = ScalarFn(ValidatedOperand.asFloat());
+
+ return handleFMFFlags(Result, FMF, false);
----------------
dtcxzyw wrote:
```suggestion
return handleFMFFlags(Result, FMF, /*IsInput=*/false);
```
https://github.com/llvm/llvm-project/pull/188453
More information about the llvm-commits
mailing list