[llvm] r177386 - The testing to ensure a vector of zeros of type floating point isn't misclassified as negative zero can be simplified, as pointed out by Duncan Sands.

David Tweed david.tweed at arm.com
Tue Mar 19 03:16:40 PDT 2013


Author: davidtweed
Date: Tue Mar 19 05:16:40 2013
New Revision: 177386

URL: http://llvm.org/viewvc/llvm-project?rev=177386&view=rev
Log:
The testing to ensure a vector of zeros of type floating point isn't misclassified as negative zero can be simplified, as pointed out by Duncan Sands.

Modified:
    llvm/trunk/lib/IR/Constants.cpp

Modified: llvm/trunk/lib/IR/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Constants.cpp?rev=177386&r1=177385&r2=177386&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Constants.cpp (original)
+++ llvm/trunk/lib/IR/Constants.cpp Tue Mar 19 05:16:40 2013
@@ -53,12 +53,9 @@ bool Constant::isNegativeZeroValue() con
       if (SplatCFP && SplatCFP->isZero() && SplatCFP->isNegative())
         return true;
 
-  // However, vectors of zeroes which are floating point represent +0.0's.
-  if (const ConstantAggregateZero *CAZ = dyn_cast<ConstantAggregateZero>(this))
-    if (const VectorType *VT = dyn_cast<VectorType>(CAZ->getType()))
-      if (VT->getElementType()->isFloatingPointTy())
-        // As it's a CAZ, we know it's the zero bit-pattern (ie, +0.0) in each element.
-        return false;
+  // We've already handled true FP case; any other FP vectors can't represent -0.0.
+  if (getType()->isFPOrFPVectorTy())
+    return false;
 
   // Otherwise, just use +0.0.
   return isNullValue();





More information about the llvm-commits mailing list