Consider expression "0.0 - X" as the negation of X if
[oota-llvm.git] / lib / IR / Constants.cpp
index 4b5859995548de8576a4af2eda12454b190332c1..812692f3fae9680a22e2df64b61be257c1d537a1 100644 (file)
@@ -51,6 +51,15 @@ bool Constant::isNegativeZeroValue() const {
   return isNullValue();
 }
 
+bool Constant::isZeroValue() const {
+  // Floating point values have an explicit -0.0 value.
+  if (const ConstantFP *CFP = dyn_cast<ConstantFP>(this))
+    return CFP->isZero();
+
+  // Otherwise, just use +0.0.
+  return isNullValue();
+}
+
 bool Constant::isNullValue() const {
   // 0 is null.
   if (const ConstantInt *CI = dyn_cast<ConstantInt>(this))