ComputeMaskedBits: sub falls through to add, and sub doesn't have the same overflow...
[oota-llvm.git] / lib / Analysis / ValueTracking.cpp
index 33fb1e8cdc8a21b9428ae912332f8b4add22a7c1..6c33d2d508e3167f29cfc61df6abbaca2798eb58 100644 (file)
@@ -431,7 +431,8 @@ void llvm::ComputeMaskedBits(Value *V, const APInt &Mask,
     }
 
     // Are we still trying to solve for the sign bit?
-    if (Mask.isNegative() && !KnownZero.isNegative() && !KnownOne.isNegative()){
+    if (I->getOpcode() == Instruction::Add &&
+        Mask.isNegative() && !KnownZero.isNegative() && !KnownOne.isNegative()){
       OverflowingBinaryOperator *OBO = cast<OverflowingBinaryOperator>(I);
       if (OBO->hasNoSignedWrap()) {
         // Adding two positive numbers can't wrap into negative ...