Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 4 additions & 2 deletions llvm/lib/Analysis/ScalarEvolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11804,8 +11804,10 @@ bool ScalarEvolution::isImpliedCond(CmpPredicate Pred, const SCEV *LHS,
MaxValue)) {
const SCEV *TruncFoundLHS = getTruncateExpr(FoundLHS, NarrowType);
const SCEV *TruncFoundRHS = getTruncateExpr(FoundRHS, NarrowType);
if (isImpliedCondBalancedTypes(Pred, LHS, RHS, FoundPred, TruncFoundLHS,
TruncFoundRHS, CtxI))
// We cannot preserve samesign after truncation.
if (isImpliedCondBalancedTypes(
Pred, LHS, RHS, static_cast<ICmpInst::Predicate>(FoundPred),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of wonder whether we should have some more explicit API for this like FoundPred.withoutSameSign(). Doing this by going through a static_cast is a bit subtle...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix it in a follow up patch.

TruncFoundLHS, TruncFoundRHS, CtxI))
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/IndVarSimplify/pr126409.ll
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ define void @pr126409() {
; CHECK: [[FOR_BODY_PREHEADER]]:
; CHECK-NEXT: br label %[[FOR_BODY:.*]]
; CHECK: [[FOR_BODY]]:
; CHECK-NEXT: br i1 true, label %[[FOR_BODY]], label %[[IF_END_LOOPEXIT:.*]]
; CHECK-NEXT: br i1 false, label %[[FOR_BODY]], label %[[IF_END_LOOPEXIT:.*]]
; CHECK: [[IF_END_LOOPEXIT]]:
; CHECK-NEXT: br label %[[IF_END]]
; CHECK: [[IF_END]]:
Expand Down