[llvm] [llubi] Initial support for floating-point numbers (PR #188453)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 1 12:06:26 PDT 2026
================
@@ -160,6 +161,51 @@ class InstExecutor : public InstVisitor<InstExecutor, void> {
CurrentFrame->ValueMap.insert_or_assign(&I, std::move(V));
}
+ APFloat handleDenormal(APFloat Val, DenormalMode::DenormalModeKind Mode,
+ bool NonDet = false) {
+ if (!Val.isDenormal())
+ return Val;
+ if (NonDet) {
+ // Non-deterministically choose between flushing or preserving the
+ // denormal value.
+ if (Ctx.getRandomBool())
+ return Val;
+ }
+ if (Mode == DenormalMode::PositiveZero)
+ return APFloat::getZero(Val.getSemantics(), false);
+ if (Mode == DenormalMode::PreserveSign)
+ return APFloat::getZero(Val.getSemantics(), Val.isNegative());
+ // Default case for IEEE, Dynamic, and Invalid
+ // Currently we treat Dynamic the same as IEEE, since we don't support
+ // changing the mode at this point.
+ return Val;
+ }
+
+ AnyValue handleFMFFlags(AnyValue Val, FastMathFlags FMF) {
+ if (Val.isPoison())
+ return AnyValue::poison();
+
+ if (Val.isAggregate()) {
+ std::vector<AnyValue> ResVec;
+ ResVec.reserve(Val.asAggregate().size());
+ for (const auto &A : Val.asAggregate())
+ ResVec.push_back(handleFMFFlags(A, FMF));
+ return AnyValue(ResVec);
+ }
+
+ const APFloat &APVal = Val.asFloat();
+ if (FMF.noNaNs() && APVal.isNaN())
+ return AnyValue::poison();
+ if (FMF.noInfs() && APVal.isInfinity())
+ return AnyValue::poison();
+ // Non-deterministically flip the sign of the input.
+ if (FMF.noSignedZeros() && APVal.isZero()) {
----------------
dtcxzyw wrote:
Missing tests for nsz.
https://github.com/llvm/llvm-project/pull/188453
More information about the llvm-commits
mailing list