Skip to content

Commit

Permalink
Have CannotBeNegativeZero() be aware of the nsz fast-math flag
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169452 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
milseman committed Dec 6, 2012
1 parent 6e34113 commit 85893f4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/Analysis/ValueTracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,12 @@ bool llvm::CannotBeNegativeZero(const Value *V, unsigned Depth) {

const Operator *I = dyn_cast<Operator>(V);
if (I == 0) return false;


// Check if the nsz fast-math flag is set
if (const FPMathOperator *FPO = dyn_cast<FPMathOperator>(I))
if (FPO->hasNoSignedZeros())
return true;

// (add x, 0.0) is guaranteed to return +0.0, not -0.0.
if (I->getOpcode() == Instruction::FAdd &&
isa<ConstantFP>(I->getOperand(1)) &&
Expand Down

0 comments on commit 85893f4

Please sign in to comment.