Skip to content

Commit 1387a68

Browse files
committed
[SCEV] Do not preserve samesign after truncation
1 parent e3b5501 commit 1387a68

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11804,8 +11804,10 @@ bool ScalarEvolution::isImpliedCond(CmpPredicate Pred, const SCEV *LHS,
1180411804
MaxValue)) {
1180511805
const SCEV *TruncFoundLHS = getTruncateExpr(FoundLHS, NarrowType);
1180611806
const SCEV *TruncFoundRHS = getTruncateExpr(FoundRHS, NarrowType);
11807-
if (isImpliedCondBalancedTypes(Pred, LHS, RHS, FoundPred, TruncFoundLHS,
11808-
TruncFoundRHS, CtxI))
11807+
// We cannot preserve samesign after truncation.
11808+
if (isImpliedCondBalancedTypes(
11809+
Pred, LHS, RHS, static_cast<ICmpInst::Predicate>(FoundPred),
11810+
TruncFoundLHS, TruncFoundRHS, CtxI))
1180911811
return true;
1181011812
}
1181111813
}

llvm/test/Transforms/IndVarSimplify/pr126409.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ define void @pr126409() {
1010
; CHECK: [[FOR_BODY_PREHEADER]]:
1111
; CHECK-NEXT: br label %[[FOR_BODY:.*]]
1212
; CHECK: [[FOR_BODY]]:
13-
; CHECK-NEXT: br i1 true, label %[[FOR_BODY]], label %[[IF_END_LOOPEXIT:.*]]
13+
; CHECK-NEXT: br i1 false, label %[[FOR_BODY]], label %[[IF_END_LOOPEXIT:.*]]
1414
; CHECK: [[IF_END_LOOPEXIT]]:
1515
; CHECK-NEXT: br label %[[IF_END]]
1616
; CHECK: [[IF_END]]:

0 commit comments

Comments
 (0)