From 1d8979422a8086dcc4a4f03a0e744edd56a70e91 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 31 Dec 2009 19:34:45 +0000 Subject: make reassociate more careful about not leaving around dead mul's llvm-svn: 92370 --- llvm/lib/Transforms/Scalar/Reassociate.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp index 8596dc70dad..365c9f79582 100644 --- a/llvm/lib/Transforms/Scalar/Reassociate.cpp +++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp @@ -530,7 +530,13 @@ Value *Reassociate::RemoveFactorFromExpression(Value *V, Value *Factor) { return 0; } - if (Factors.size() == 1) return Factors[0].Op; + // If this was just a single multiply, remove the multiply and return the only + // remaining operand. + if (Factors.size() == 1) { + ValueRankMap.erase(BO); + BO->eraseFromParent(); + return Factors[0].Op; + } RewriteExprTree(BO, Factors); return BO; -- cgit v1.2.3