OSDN Git Service

[ValueTracking] simplify code in CannotBeNegativeZero() with match(); NFCI
authorSanjay Patel <spatel@rotateright.com>
Mon, 13 Nov 2017 17:40:47 +0000 (17:40 +0000)
committerSanjay Patel <spatel@rotateright.com>
Mon, 13 Nov 2017 17:40:47 +0000 (17:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318055 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ValueTracking.cpp

index 9a0df74..af35e4f 100644 (file)
@@ -2607,11 +2607,9 @@ bool llvm::CannotBeNegativeZero(const Value *V, const TargetLibraryInfo *TLI,
     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))