diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-12-31 08:33:49 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-12-31 08:33:49 +0000 |
| commit | 4e3a5678afc6d4f9bd8a7f8f7dd00a8e2b27518a (patch) | |
| tree | 4aa0db6eaa49103bc22befa3305dfa6a468a4b7c /llvm/lib/Transforms | |
| parent | 2d3b53a68c9e569d4ebbcffb8498935e6bf8f8cb (diff) | |
| download | bcm5719-llvm-4e3a5678afc6d4f9bd8a7f8f7dd00a8e2b27518a.tar.gz bcm5719-llvm-4e3a5678afc6d4f9bd8a7f8f7dd00a8e2b27518a.zip | |
simple fix for an incorrect factoring which causes a
miscompilation, PR5458.
llvm-svn: 92354
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/Reassociate.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp index a2d6f082973..195bd69a4c3 100644 --- a/llvm/lib/Transforms/Scalar/Reassociate.cpp +++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp @@ -714,6 +714,10 @@ Value *Reassociate::OptimizeExpression(BinaryOperator *I, // To efficiently find this, we count the number of times a factor occurs // for any ADD operands that are MULs. DenseMap<Value*, unsigned> FactorOccurrences; + + // Keep track of each multiply we see, to avoid triggering on (X*4)+(X*4) + // where they are actually the same multiply. + SmallPtrSet<BinaryOperator*, 4> Multiplies; unsigned MaxOcc = 0; Value *MaxOccVal = 0; for (unsigned i = 0, e = Ops.size(); i != e; ++i) { @@ -721,6 +725,9 @@ Value *Reassociate::OptimizeExpression(BinaryOperator *I, if (BOp == 0 || BOp->getOpcode() != Instruction::Mul || !BOp->use_empty()) continue; + // If we've already seen this multiply, don't revisit it. + if (!Multiplies.insert(BOp)) continue; + // Compute all of the factors of this added value. SmallVector<Value*, 8> Factors; FindSingleUseMultiplyFactors(BOp, Factors); |

