Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,18 +859,18 @@ void State::addInfoForInductions(BasicBlock &BB) {
return;

auto *AR = dyn_cast_or_null<SCEVAddRecExpr>(SE.getSCEV(PN));
if (!AR)
BasicBlock *LoopPred = L->getLoopPredecessor();
if (!AR || !LoopPred)
return;

const SCEV *StartSCEV = AR->getStart();
Value *StartValue = nullptr;
if (auto *C = dyn_cast<SCEVConstant>(StartSCEV))
if (auto *C = dyn_cast<SCEVConstant>(StartSCEV)) {
StartValue = C->getValue();
else if (auto *U = dyn_cast<SCEVUnknown>(StartSCEV))
StartValue = U->getValue();

if (!StartValue)
return;
} else {
StartValue = PN->getIncomingValueForBlock(LoopPred);
assert(SE.getSCEV(StartValue) == StartSCEV && "inconsistent start value");
}

DomTreeNode *DTN = DT.getNode(InLoopSucc);
auto Inc = SE.getMonotonicPredicateType(AR, CmpInst::ICMP_UGT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ define void @start_value_of_inner_add_rec_is_add_rec_condition_can_be_simplified
; CHECK-NEXT: [[CMP2_NOT:%.*]] = icmp eq i32 [[K_0]], [[LEN]]
; CHECK-NEXT: br i1 [[CMP2_NOT]], label [[OUTER_LATCH]], label [[INNER_LATCH]]
; CHECK: inner.latch:
; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult i32 [[K_0]], [[LEN]]
; CHECK-NEXT: call void @use(i1 [[CMP_NOT_I]])
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: [[K_INC]] = add i32 [[K_0]], 1
; CHECK-NEXT: br label [[INNER_HEADER]]
; CHECK: outer.latch:
Expand Down