[llvm] [KnownFPClass] Add neg_square and fma_neg_square (PR #227248)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 30 04:52:44 PDT 2026
================
@@ -287,6 +287,27 @@ struct KnownFPClass {
return Known;
}
+ // Special cases of fmul -x, x and fmul x, -x.
+ static KnownFPClass
+ neg_square(const KnownFPClass &Src,
+ DenormalMode Mode = DenormalMode::getDynamic()) {
+ KnownFPClass Known = fmul(fneg(Src), Src, Mode);
+
+ // -X * X is always negative, zero, or a NaN.
+ Known.knownNot(fcPosSubnormal | fcPosNormal | fcPosInf);
+
+ // Zero results are -0 unless a denormal is flushed to +0.
+ if ((Mode.Input == DenormalMode::IEEE ||
+ Mode.Input == DenormalMode::PreserveSign) &&
+ (Mode.Output == DenormalMode::IEEE ||
+ Mode.Output == DenormalMode::PreserveSign)) {
+ Known.knownNot(fcPosZero);
----------------
arsenm wrote:
I think you can't conclude this without a range check. A denormal input can still underflow to 0
https://github.com/llvm/llvm-project/pull/227248
More information about the llvm-commits
mailing list