From 0f12837be0a736623c51c8a6499cda66ccc64c26 Mon Sep 17 00:00:00 2001 From: Michael Ilseman Date: Thu, 6 Dec 2012 00:07:09 +0000 Subject: [PATCH] Have CannotBeNegativeZero() be aware of the nsz fast-math flag llvm-svn: 169452 --- llvm/lib/Analysis/ValueTracking.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 47b1db6..eee231d 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -1312,7 +1312,12 @@ bool llvm::CannotBeNegativeZero(const Value *V, unsigned Depth) { const Operator *I = dyn_cast(V); if (I == 0) return false; - + + // Check if the nsz fast-math flag is set + if (const FPMathOperator *FPO = dyn_cast(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(I->getOperand(1)) && -- 2.7.4