diff options
author | Dan Gohman <gohman@apple.com> | 2010-08-29 15:10:06 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-08-29 15:10:06 +0000 |
commit | 3e6fc18943e8ef8d68c8796c62a540e789840bd5 (patch) | |
tree | 24b22859ac448ded478d472c34925f4321730c43 | |
parent | 7712d2900dc4b539df955253c9df3bc1fbc35022 (diff) | |
download | bcm5719-llvm-3e6fc18943e8ef8d68c8796c62a540e789840bd5.tar.gz bcm5719-llvm-3e6fc18943e8ef8d68c8796c62a540e789840bd5.zip |
Batch up subtracts along with adds, when analyzing long chains of
operations.
llvm-svn: 112432
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 863f8a65409..121c6e2a327 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -3332,11 +3332,16 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) { // LLVM IR canonical form means we need only traverse the left operands. SmallVector<const SCEV *, 4> AddOps; AddOps.push_back(getSCEV(U->getOperand(1))); - for (Value *Op = U->getOperand(0); - Op->getValueID() == Instruction::Add + Value::InstructionVal; - Op = U->getOperand(0)) { + for (Value *Op = U->getOperand(0); ; Op = U->getOperand(0)) { + unsigned Opcode = Op->getValueID() - Value::InstructionVal; + if (Opcode != Instruction::Add && Opcode != Instruction::Sub) + break; U = cast<Operator>(Op); - AddOps.push_back(getSCEV(U->getOperand(1))); + const SCEV *Op1 = getSCEV(U->getOperand(1)); + if (Opcode == Instruction::Sub) + AddOps.push_back(getNegativeSCEV(Op1)); + else + AddOps.push_back(Op1); } AddOps.push_back(getSCEV(U->getOperand(0))); return getAddExpr(AddOps); |