[PATCH] D28927: [ValueTracking] Add comment that CannotBeOrderedLessThanZero does the wrong thing for powi.
Justin Lebar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 26 17:09:57 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293243: [ValueTracking] Add comment that CannotBeOrderedLessThanZero does the wrong… (authored by jlebar).
Changed prior to commit:
https://reviews.llvm.org/D28927?vs=85098&id=85991#toc
Repository:
rL LLVM
https://reviews.llvm.org/D28927
Files:
llvm/trunk/lib/Analysis/ValueTracking.cpp
Index: llvm/trunk/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp
@@ -2602,6 +2602,11 @@
const TargetLibraryInfo *TLI,
bool SignBitOnly,
unsigned Depth) {
+ // TODO: This function does not do the right thing when SignBitOnly is true
+ // and we're lowering to a hypothetical IEEE 754-compliant-but-evil platform
+ // which flips the sign bits of NaNs. See
+ // https://llvm.org/bugs/show_bug.cgi?id=31702.
+
if (const ConstantFP *CFP = dyn_cast<ConstantFP>(V)) {
return !CFP->getValueAPF().isNegative() ||
(!SignBitOnly && CFP->getValueAPF().isZero());
@@ -2678,8 +2683,22 @@
if (Exponent->getBitWidth() <= 64 && Exponent->getSExtValue() % 2u == 0)
return true;
}
+ // TODO: This is not correct. Given that exp is an integer, here are the
+ // ways that pow can return a negative value:
+ //
+ // pow(x, exp) --> negative if exp is odd and x is negative.
+ // pow(-0, exp) --> -inf if exp is negative odd.
+ // pow(-0, exp) --> -0 if exp is positive odd.
+ // pow(-inf, exp) --> -0 if exp is negative odd.
+ // pow(-inf, exp) --> -inf if exp is positive odd.
+ //
+ // Therefore, if !SignBitOnly, we can return true if x >= +0 or x is NaN,
+ // but we must return false if x == -0. Unfortunately we do not currently
+ // have a way of expressing this constraint. See details in
+ // https://llvm.org/bugs/show_bug.cgi?id=31702.
return cannotBeOrderedLessThanZeroImpl(I->getOperand(0), TLI, SignBitOnly,
Depth + 1);
+
case Intrinsic::fma:
case Intrinsic::fmuladd:
// x*x+y is non-negative if y is non-negative.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28927.85991.patch
Type: text/x-patch
Size: 1995 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170127/9023acbc/attachment.bin>
More information about the llvm-commits
mailing list