theoretically the negate we find could be in a different function, check
authorChris Lattner <sabre@nondot.org>
Sat, 2 Jan 2010 21:46:33 +0000 (21:46 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 2 Jan 2010 21:46:33 +0000 (21:46 +0000)
for this case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92425 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/Reassociate.cpp

index 827b47d3feeb8718aa6afc0d322b537f34c035ad..71d787a839a73b380d514f7e33bc8de145839494 100644 (file)
@@ -414,6 +414,10 @@ static Value *NegateValue(Value *V, Instruction *BI) {
     // non-instruction value) or right after the definition.  These negates will
     // be zapped by reassociate later, so we don't need much finesse here.
     BinaryOperator *TheNeg = cast<BinaryOperator>(*UI);
+
+    // Verify that the negate is in this function, V might be a constant expr.
+    if (TheNeg->getParent()->getParent() != BI->getParent()->getParent())
+      continue;
     
     BasicBlock::iterator InsertPt;
     if (Instruction *InstInput = dyn_cast<Instruction>(V)) {