diff options
author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-04-11 15:26:18 +0000 |
---|---|---|
committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-04-11 15:26:18 +0000 |
commit | f9d88e650b89aebb0af85cd00639b55e740f2569 (patch) | |
tree | 1a12d4855f7021ade2d20b4e3c7080596edc7567 /llvm/lib/Analysis/ScalarEvolution.cpp | |
parent | e578e970cb979d000e6b1d734b406aa06d9313d4 (diff) | |
download | bcm5719-llvm-f9d88e650b89aebb0af85cd00639b55e740f2569.tar.gz bcm5719-llvm-f9d88e650b89aebb0af85cd00639b55e740f2569.zip |
This reverts commit r265913 and r265912
See PR27315
r265913: "[IndVars] Eliminate op.with.overflow when possible"
r265912: "[SCEV] See through op.with.overflow intrinsics"
llvm-svn: 265950
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 54 |
1 files changed, 5 insertions, 49 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 6366e3621ae..654a766b416 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -3831,7 +3831,7 @@ struct BinaryOp { /// Try to map \p V into a BinaryOp, and return \c None on failure. -static Optional<BinaryOp> MatchBinaryOp(Value *V, DominatorTree &DT) { +static Optional<BinaryOp> MatchBinaryOp(Value *V) { auto *Op = dyn_cast<Operator>(V); if (!Op) return None; @@ -3877,50 +3877,6 @@ static Optional<BinaryOp> MatchBinaryOp(Value *V, DominatorTree &DT) { } return BinaryOp(Op); - case Instruction::ExtractValue: { - auto *EVI = cast<ExtractValueInst>(Op); - if (EVI->getNumIndices() != 1 || EVI->getIndices()[0] != 0) - break; - - auto *CI = dyn_cast<CallInst>(EVI->getAggregateOperand()); - if (!CI) - break; - - if (auto *F = CI->getCalledFunction()) - switch (F->getIntrinsicID()) { - case Intrinsic::sadd_with_overflow: - case Intrinsic::uadd_with_overflow: { - if (!isOverflowIntrinsicNoWrap(cast<IntrinsicInst>(CI), DT)) - return BinaryOp(Instruction::Add, CI->getArgOperand(0), - CI->getArgOperand(1)); - - // Now that we know that all uses of the arithmetic-result component of - // CI are guarded by the overflow check, we can go ahead and pretend - // that the arithmetic is non-overflowing. - if (F->getIntrinsicID() == Intrinsic::sadd_with_overflow) - return BinaryOp(Instruction::Add, CI->getArgOperand(0), - CI->getArgOperand(1), /* IsNSW = */ true, - /* IsNUW = */ false); - else - return BinaryOp(Instruction::Add, CI->getArgOperand(0), - CI->getArgOperand(1), /* IsNSW = */ false, - /* IsNUW*/ true); - } - - case Intrinsic::ssub_with_overflow: - case Intrinsic::usub_with_overflow: - return BinaryOp(Instruction::Sub, CI->getArgOperand(0), - CI->getArgOperand(1)); - - case Intrinsic::smul_with_overflow: - case Intrinsic::umul_with_overflow: - return BinaryOp(Instruction::Mul, CI->getArgOperand(0), - CI->getArgOperand(1)); - default: - break; - } - } - default: break; } @@ -3997,7 +3953,7 @@ const SCEV *ScalarEvolution::createAddRecFromPHI(PHINode *PN) { // If the increment doesn't overflow, then neither the addrec nor // the post-increment will overflow. - if (auto BO = MatchBinaryOp(BEValueV, DT)) { + if (auto BO = MatchBinaryOp(BEValueV)) { if (BO->Opcode == Instruction::Add && BO->LHS == PN) { if (BO->IsNUW) Flags = setFlags(Flags, SCEV::FlagNUW); @@ -4877,7 +4833,7 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) { return getUnknown(V); Operator *U = cast<Operator>(V); - if (auto BO = MatchBinaryOp(U, DT)) { + if (auto BO = MatchBinaryOp(U)) { switch (BO->Opcode) { case Instruction::Add: { // The simple thing to do would be to just call getSCEV on both operands @@ -4918,7 +4874,7 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) { else AddOps.push_back(getSCEV(BO->RHS)); - auto NewBO = MatchBinaryOp(BO->LHS, DT); + auto NewBO = MatchBinaryOp(BO->LHS); if (!NewBO || (NewBO->Opcode != Instruction::Add && NewBO->Opcode != Instruction::Sub)) { AddOps.push_back(getSCEV(BO->LHS)); @@ -4948,7 +4904,7 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) { } MulOps.push_back(getSCEV(BO->RHS)); - auto NewBO = MatchBinaryOp(BO->LHS, DT); + auto NewBO = MatchBinaryOp(BO->LHS); if (!NewBO || NewBO->Opcode != Instruction::Mul) { MulOps.push_back(getSCEV(BO->LHS)); break; |