Make this work for FP constantexprs
authorChris Lattner <sabre@nondot.org>
Mon, 17 Oct 2005 20:18:38 +0000 (20:18 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 17 Oct 2005 20:18:38 +0000 (20:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23773 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index d92e126b080c8e15ed3b53ae02853f283ca9bc95..f4d44a17755132160b023065d1b5af35c663d562 100644 (file)
@@ -697,8 +697,9 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
     if (!I.getType()->isFloatingPoint()) { // NOTE: -0 + +0 = +0.
       if (RHSC->isNullValue())
         return ReplaceInstUsesWith(I, LHS);
-    } else if (cast<ConstantFP>(RHSC)->isExactlyValue(-0.0)) {
-      return ReplaceInstUsesWith(I, LHS);
+    } else if (ConstantFP *CFP = dyn_cast<ConstantFP>(RHSC)) {
+      if (CFP->isExactlyValue(-0.0))
+        return ReplaceInstUsesWith(I, LHS);
     }
 
     // X + (signbit) --> X ^ signbit