mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-14 14:24:05 +00:00
Revert r230280: "Bugfix: SCEVExpander incorrectly marks increment operations as no-wrap"
This caused PR22674, failing this assert: Instructions.h:2281: llvm::Value* llvm::PHINode::getOperand(unsigned int) const: Assertion `i_nocapture < OperandTraits<PHINode>::operands(this) && "getOperand() out of range!"' failed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230341 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1063,34 +1063,6 @@ static bool canBeCheaplyTransformed(ScalarEvolution &SE,
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool IsIncrementNSW(ScalarEvolution &SE, const SCEVAddRecExpr *AR) {
|
||||
if (!isa<IntegerType>(AR->getType()))
|
||||
return false;
|
||||
|
||||
unsigned BitWidth = cast<IntegerType>(AR->getType())->getBitWidth();
|
||||
Type *WideTy = IntegerType::get(AR->getType()->getContext(), BitWidth * 2);
|
||||
const SCEV *Step = AR->getStepRecurrence(SE);
|
||||
const SCEV *OpAfterExtend = SE.getAddExpr(SE.getSignExtendExpr(Step, WideTy),
|
||||
SE.getSignExtendExpr(AR, WideTy));
|
||||
const SCEV *ExtendAfterOp =
|
||||
SE.getSignExtendExpr(SE.getAddExpr(AR, Step), WideTy);
|
||||
return ExtendAfterOp == OpAfterExtend;
|
||||
}
|
||||
|
||||
static bool IsIncrementNUW(ScalarEvolution &SE, const SCEVAddRecExpr *AR) {
|
||||
if (!isa<IntegerType>(AR->getType()))
|
||||
return false;
|
||||
|
||||
unsigned BitWidth = cast<IntegerType>(AR->getType())->getBitWidth();
|
||||
Type *WideTy = IntegerType::get(AR->getType()->getContext(), BitWidth * 2);
|
||||
const SCEV *Step = AR->getStepRecurrence(SE);
|
||||
const SCEV *OpAfterExtend = SE.getAddExpr(SE.getZeroExtendExpr(Step, WideTy),
|
||||
SE.getZeroExtendExpr(AR, WideTy));
|
||||
const SCEV *ExtendAfterOp =
|
||||
SE.getZeroExtendExpr(SE.getAddExpr(AR, Step), WideTy);
|
||||
return ExtendAfterOp == OpAfterExtend;
|
||||
}
|
||||
|
||||
/// getAddRecExprPHILiterally - Helper for expandAddRecExprLiterally. Expand
|
||||
/// the base addrec, which is the addrec without any non-loop-dominating
|
||||
/// values, and return the PHI.
|
||||
@ -1241,11 +1213,10 @@ SCEVExpander::getAddRecExprPHILiterally(const SCEVAddRecExpr *Normalized,
|
||||
IVIncInsertPos : Pred->getTerminator();
|
||||
Builder.SetInsertPoint(InsertPos);
|
||||
Value *IncV = expandIVInc(PN, StepV, L, ExpandTy, IntTy, useSubtract);
|
||||
|
||||
if (isa<OverflowingBinaryOperator>(IncV)) {
|
||||
if (IsIncrementNUW(SE, Normalized))
|
||||
if (Normalized->getNoWrapFlags(SCEV::FlagNUW))
|
||||
cast<BinaryOperator>(IncV)->setHasNoUnsignedWrap();
|
||||
if (IsIncrementNSW(SE, Normalized))
|
||||
if (Normalized->getNoWrapFlags(SCEV::FlagNSW))
|
||||
cast<BinaryOperator>(IncV)->setHasNoSignedWrap();
|
||||
}
|
||||
PN->addIncoming(IncV, Pred);
|
||||
|
Reference in New Issue
Block a user