[llvm] r318055 - [ValueTracking] simplify code in CannotBeNegativeZero() with match(); NFCI

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 13 09:40:47 PST 2017


Author: spatel
Date: Mon Nov 13 09:40:47 2017
New Revision: 318055

URL: http://llvm.org/viewvc/llvm-project?rev=318055&view=rev
Log:
[ValueTracking] simplify code in CannotBeNegativeZero() with match(); NFCI

Modified:
    llvm/trunk/lib/Analysis/ValueTracking.cpp

Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=318055&r1=318054&r2=318055&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Mon Nov 13 09:40:47 2017
@@ -2607,11 +2607,9 @@ bool llvm::CannotBeNegativeZero(const Va
     if (FPO->hasNoSignedZeros())
       return true;
 
-  // (add x, 0.0) is guaranteed to return +0.0, not -0.0.
-  if (I->getOpcode() == Instruction::FAdd)
-    if (ConstantFP *CFP = dyn_cast<ConstantFP>(I->getOperand(1)))
-      if (CFP->isNullValue())
-        return true;
+  // (fadd x, 0.0) is guaranteed to return +0.0, not -0.0.
+  if (match(I, m_FAdd(m_Value(), m_Zero())))
+    return true;
 
   // sitofp and uitofp turn into +0.0 for zero.
   if (isa<SIToFPInst>(I) || isa<UIToFPInst>(I))




More information about the llvm-commits mailing list