[PATCH] D148631: ValueTracking: fdiv sign handling in computeKnownFPClass
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 19 01:23:28 PDT 2023
foad added inline comments.
================
Comment at: llvm/include/llvm/Analysis/ValueTracking.h:357-358
+ void signBitMustBeZero() {
KnownFPClasses = (KnownFPClasses & fcPositive) |
(KnownFPClasses & fcNan);
SignBit = false;
----------------
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:4564
- if (KnowSomethingUseful && WantInfNan) {
+ if (KnowSomethingUseful && (WantInfNan || WantNegative)) {
computeKnownFPClass(Op->getOperand(0), DemandedElts,
----------------
`WantInfNan || WantNegative` is true, else we would have bailed out
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:4582-4584
+ // X / -0.0 is -Inf (or NaN).
+ if (KnownLHS.cannotBeOrderedLessThanZero() && KnownRHS.signBitIsZeroOrNaN())
+ Known.knownNot(KnownFPClass::OrderedLessThanZeroMask);
----------------
This may be true but it seems weirdly specific, and the comment doesn't really say what it does.
I think it generalises to:
```
if (KnownLHS.isKnownNot(fcNegative) && KnownRHS.isKnownNot(fcNegative))
Known.knownNot(fcNegative);
```
... plus three other cases for the other combinations of LHS/RHS known not positive/negative.
This is basically saying that ignoring nans, the sign of the result is the xor of the signs of the arguments, which is also true for FMul.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148631/new/
https://reviews.llvm.org/D148631
More information about the llvm-commits
mailing list