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 | b8fc62bc58d945a4e820ee3676c17793e8770b3a (patch) | |
tree | 6972ce9e5c825029b5cbd56a74c1d6715644c8fc /lib/Analysis/ScalarEvolution.cpp | |
parent | c6a8e99fb34f039d5e410409f21cc03802059e59 (diff) |
Batch up subtracts along with adds, when analyzing long chains of
operations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112432 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 863f8a6540..121c6e2a32 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/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); |