mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[IndVars] Use isLoopBackedgeGuardedByCond for last iteration check
Use more context to prove contextual facts about the last iteration. It is only executed when the backedge is taken, so we can use `isLoopBackedgeGuardedByCond` to make this check. Differential Revision: https://reviews.llvm.org/D91535 Reviewed By: skatkov
This commit is contained in:
parent
f2e1d4a8ac
commit
ed766a594f
@ -9673,7 +9673,7 @@ ScalarEvolution::getLoopInvariantExitCondDuringFirstIterations(
|
||||
// Value of IV on suggested last iteration.
|
||||
const SCEV *Last = AR->evaluateAtIteration(MaxIter, *this);
|
||||
// Does it still meet the requirement?
|
||||
if (!isKnownPredicateAt(Pred, Last, RHS, Context))
|
||||
if (!isLoopBackedgeGuardedByCond(L, Pred, Last, RHS))
|
||||
return None;
|
||||
// Because step is +/- 1 and MaxIter has same type as Start (i.e. it does
|
||||
// not exceed max unsigned value of this type), this effectively proves
|
||||
|
@ -835,15 +835,16 @@ define void @test_can_predicate_simple_unsigned_different_start(i32 %start, i32*
|
||||
; CHECK-LABEL: @test_can_predicate_simple_unsigned_different_start(
|
||||
; CHECK-NEXT: preheader:
|
||||
; CHECK-NEXT: [[LEN:%.*]] = load i32, i32* [[P:%.*]], align 4
|
||||
; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[START:%.*]], -1
|
||||
; CHECK-NEXT: br label [[LOOP:%.*]]
|
||||
; CHECK: loop:
|
||||
; CHECK-NEXT: [[IV:%.*]] = phi i32 [ [[START:%.*]], [[PREHEADER:%.*]] ], [ [[IV_NEXT:%.*]], [[BACKEDGE:%.*]] ]
|
||||
; CHECK-NEXT: [[IV:%.*]] = phi i32 [ [[START]], [[PREHEADER:%.*]] ], [ [[IV_NEXT:%.*]], [[BACKEDGE:%.*]] ]
|
||||
; CHECK-NEXT: [[ZERO_COND:%.*]] = icmp eq i32 [[IV]], 0
|
||||
; CHECK-NEXT: br i1 [[ZERO_COND]], label [[EXIT:%.*]], label [[RANGE_CHECK_BLOCK:%.*]]
|
||||
; CHECK: range_check_block:
|
||||
; CHECK-NEXT: [[IV_NEXT]] = sub i32 [[IV]], 1
|
||||
; CHECK-NEXT: [[RANGE_CHECK:%.*]] = icmp ult i32 [[IV_NEXT]], [[LEN]]
|
||||
; CHECK-NEXT: br i1 [[RANGE_CHECK]], label [[BACKEDGE]], label [[FAIL:%.*]]
|
||||
; CHECK-NEXT: [[RANGE_CHECK1:%.*]] = icmp ult i32 [[TMP0]], [[LEN]]
|
||||
; CHECK-NEXT: br i1 [[RANGE_CHECK1]], label [[BACKEDGE]], label [[FAIL:%.*]]
|
||||
; CHECK: backedge:
|
||||
; CHECK-NEXT: [[EL_PTR:%.*]] = getelementptr i32, i32* [[P]], i32 [[IV]]
|
||||
; CHECK-NEXT: [[EL:%.*]] = load i32, i32* [[EL_PTR]], align 4
|
||||
@ -885,15 +886,16 @@ define void @test_can_predicate_simple_unsigned_inverted_different_start(i32 %st
|
||||
; CHECK-LABEL: @test_can_predicate_simple_unsigned_inverted_different_start(
|
||||
; CHECK-NEXT: preheader:
|
||||
; CHECK-NEXT: [[LEN:%.*]] = load i32, i32* [[P:%.*]], align 4
|
||||
; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[START:%.*]], -1
|
||||
; CHECK-NEXT: br label [[LOOP:%.*]]
|
||||
; CHECK: loop:
|
||||
; CHECK-NEXT: [[IV:%.*]] = phi i32 [ [[START:%.*]], [[PREHEADER:%.*]] ], [ [[IV_NEXT:%.*]], [[BACKEDGE:%.*]] ]
|
||||
; CHECK-NEXT: [[IV:%.*]] = phi i32 [ [[START]], [[PREHEADER:%.*]] ], [ [[IV_NEXT:%.*]], [[BACKEDGE:%.*]] ]
|
||||
; CHECK-NEXT: [[ZERO_COND:%.*]] = icmp eq i32 [[IV]], 0
|
||||
; CHECK-NEXT: br i1 [[ZERO_COND]], label [[EXIT:%.*]], label [[RANGE_CHECK_BLOCK:%.*]]
|
||||
; CHECK: range_check_block:
|
||||
; CHECK-NEXT: [[IV_NEXT]] = sub i32 [[IV]], 1
|
||||
; CHECK-NEXT: [[RANGE_CHECK:%.*]] = icmp uge i32 [[IV_NEXT]], [[LEN]]
|
||||
; CHECK-NEXT: br i1 [[RANGE_CHECK]], label [[FAIL:%.*]], label [[BACKEDGE]]
|
||||
; CHECK-NEXT: [[RANGE_CHECK1:%.*]] = icmp uge i32 [[TMP0]], [[LEN]]
|
||||
; CHECK-NEXT: br i1 [[RANGE_CHECK1]], label [[FAIL:%.*]], label [[BACKEDGE]]
|
||||
; CHECK: backedge:
|
||||
; CHECK-NEXT: [[EL_PTR:%.*]] = getelementptr i32, i32* [[P]], i32 [[IV]]
|
||||
; CHECK-NEXT: [[EL:%.*]] = load i32, i32* [[EL_PTR]], align 4
|
||||
|
Loading…
Reference in New Issue
Block a user