[PATCH] D148230: ValueTracking: fadd +0 cannot return -0

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 13 08:30:40 PDT 2023


foad added inline comments.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:4369
+    if (KnownRHS.KnownFPClasses == fcPosZero && Op->getOpcode() == Instruction::FAdd)
+      Known.knownNot(fcNegZero);
+
----------------
arsenm wrote:
> kpn wrote:
> > We're in the default FP environment here since we're looking at FAdd and FSub instructions. The check for FAdd isn't needed?
> I was just copying from CannotBeNegativeZero but I guess we can improve on it at the same time 
As I understand it, with default rounding the only addition that can return -0 is -0 + -0. So if either operand is known not to be -0, the result cannot be -0. And the only subtraction that can return -0 is -0 - +0.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148230/new/

https://reviews.llvm.org/D148230



More information about the llvm-commits mailing list