diff --git a/llvm/test/Transforms/LoopPredication/basic.ll b/llvm/test/Transforms/LoopPredication/basic.ll index b9b2314ba781..e71a8b113a83 100644 --- a/llvm/test/Transforms/LoopPredication/basic.ll +++ b/llvm/test/Transforms/LoopPredication/basic.ll @@ -1602,19 +1602,21 @@ define i32 @ne_latch_zext(i32* %array, i32 %length, i16 %n16) { ; CHECK-LABEL: @ne_latch_zext( ; CHECK-NEXT: loop.preheader: ; CHECK-NEXT: [[N:%.*]] = zext i16 [[N16:%.*]] to i32 +; CHECK-NEXT: [[NPLUS1:%.*]] = add nuw nsw i32 [[N]], 1 ; CHECK-NEXT: br label [[LOOP:%.*]] ; CHECK: loop: ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[LOOP]] ], [ 0, [[LOOP_PREHEADER:%.*]] ] ; CHECK-NEXT: [[WITHIN_BOUNDS:%.*]] = icmp ult i32 [[I]], [[LENGTH:%.*]] ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WITHIN_BOUNDS]], i32 9) [ "deopt"() ] -; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1 -; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ne i32 [[I_NEXT]], [[N]] +; CHECK-NEXT: [[I_NEXT]] = add nuw nsw i32 [[I]], 1 +; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ne i32 [[I_NEXT]], [[NPLUS1]] ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT:%.*]] ; CHECK: exit: ; CHECK-NEXT: ret i32 0 ; loop.preheader: %n = zext i16 %n16 to i32 + %nplus1 = add nsw nuw i32 %n, 1 br label %loop loop: @@ -1622,8 +1624,8 @@ loop: %within.bounds = icmp ult i32 %i, %length call void (i1, ...) @llvm.experimental.guard(i1 %within.bounds, i32 9) [ "deopt"() ] - %i.next = add nuw i32 %i, 1 - %continue = icmp ne i32 %i.next, %n + %i.next = add nsw nuw i32 %i, 1 + %continue = icmp ne i32 %i.next, %nplus1 br i1 %continue, label %loop, label %exit exit: @@ -1669,6 +1671,7 @@ define i32 @ne_latch_dom_check(i32* %array, i32 %length, i32 %n) { ; CHECK-LABEL: @ne_latch_dom_check( ; CHECK-NEXT: entry: ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0 +; CHECK-NEXT: [[NPLUS1:%.*]] = add nuw i32 [[N]], 1 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] ; CHECK: loop.preheader: ; CHECK-NEXT: br label [[LOOP:%.*]] @@ -1676,8 +1679,8 @@ define i32 @ne_latch_dom_check(i32* %array, i32 %length, i32 %n) { ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[LOOP]] ], [ 0, [[LOOP_PREHEADER]] ] ; CHECK-NEXT: [[WITHIN_BOUNDS:%.*]] = icmp ult i32 [[I]], [[LENGTH:%.*]] ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WITHIN_BOUNDS]], i32 9) [ "deopt"() ] -; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1 -; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ne i32 [[I_NEXT]], [[N]] +; CHECK-NEXT: [[I_NEXT]] = add nuw nsw i32 [[I]], 1 +; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ne i32 [[I_NEXT]], [[NPLUS1]] ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]] ; CHECK: exit.loopexit: ; CHECK-NEXT: br label [[EXIT]] @@ -1686,6 +1689,7 @@ define i32 @ne_latch_dom_check(i32* %array, i32 %length, i32 %n) { ; entry: %tmp5 = icmp sle i32 %n, 0 + %nplus1 = add nuw i32 %n, 1 br i1 %tmp5, label %exit, label %loop.preheader loop.preheader: @@ -1696,8 +1700,8 @@ loop: %within.bounds = icmp ult i32 %i, %length call void (i1, ...) @llvm.experimental.guard(i1 %within.bounds, i32 9) [ "deopt"() ] - %i.next = add nuw i32 %i, 1 - %continue = icmp ne i32 %i.next, %n + %i.next = add nsw nuw i32 %i, 1 + %continue = icmp ne i32 %i.next, %nplus1 br i1 %continue, label %loop, label %exit exit: