summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2012-06-13 12:15:56 +0000
committerDuncan Sands <baldrick@free.fr>2012-06-13 12:15:56 +0000
commit409d8ae165ee12435eafd799d384e8ce3b6b58df (patch)
treef0e53098ea8ab8bd6ae2f75a92e6b2533ddc146f /llvm/lib/Transforms
parent318a89ddacd6f4c9044b2e85bdab42bda4dac2cd (diff)
downloadbcm5719-llvm-409d8ae165ee12435eafd799d384e8ce3b6b58df.tar.gz
bcm5719-llvm-409d8ae165ee12435eafd799d384e8ce3b6b58df.zip
It is possible for several constants which aren't individually absorbing to
combine to the absorbing element. Thanks to nbjoerg on IRC for pointing this out. llvm-svn: 158399
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/Reassociate.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp
index ed7340f7e6d..66fa0744b84 100644
--- a/llvm/lib/Transforms/Scalar/Reassociate.cpp
+++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp
@@ -629,8 +629,13 @@ static bool LinearizeExprTree(BinaryOperator *I,
// Add any constants back into Ops, all globbed together and reduced to having
// weight 1 for the convenience of users.
Constant *Identity = ConstantExpr::getBinOpIdentity(Opcode, I->getType());
- if (Cst && Cst != Identity)
+ if (Cst && Cst != Identity) {
+ // If combining multiple constants resulted in the absorber then the entire
+ // expression must evaluate to the absorber.
+ if (Cst == Absorber)
+ Ops.clear();
Ops.push_back(std::make_pair(Cst, APInt(Bitwidth, 1)));
+ }
// For nilpotent operations or addition there may be no operands, for example
// because the expression was "X xor X" or consisted of 2^Bitwidth additions:
OpenPOWER on IntegriCloud