1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

[Test] One more IndVars test with inverted exit condition

This commit is contained in:
Max Kazantsev 2020-11-13 16:02:31 +07:00
parent f7d73f2bcb
commit aa03b5d94b

View File

@ -673,4 +673,58 @@ fail:
unreachable
}
define void @test_can_predicate_trunc_unsigned_inverted(i32* %p, i32* %arr) {
; CHECK-LABEL: @test_can_predicate_trunc_unsigned_inverted(
; CHECK-NEXT: preheader:
; CHECK-NEXT: [[LEN:%.*]] = load i32, i32* [[P:%.*]], align 4
; CHECK-NEXT: [[START:%.*]] = zext i32 [[LEN]] to i64
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: loop:
; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[START]], [[PREHEADER:%.*]] ], [ [[IV_NEXT:%.*]], [[BACKEDGE:%.*]] ]
; CHECK-NEXT: [[ZERO_COND:%.*]] = icmp eq i64 [[IV]], 0
; CHECK-NEXT: br i1 [[ZERO_COND]], label [[EXIT:%.*]], label [[RANGE_CHECK_BLOCK:%.*]]
; CHECK: range_check_block:
; CHECK-NEXT: [[IV_NEXT]] = sub nsw i64 [[IV]], 1
; CHECK-NEXT: [[NARROW:%.*]] = trunc i64 [[IV_NEXT]] to i32
; CHECK-NEXT: [[RANGE_CHECK:%.*]] = icmp uge i32 [[NARROW]], [[LEN]]
; CHECK-NEXT: br i1 [[RANGE_CHECK]], label [[FAIL:%.*]], label [[BACKEDGE]]
; CHECK: backedge:
; CHECK-NEXT: [[EL_PTR:%.*]] = getelementptr i32, i32* [[ARR:%.*]], i64 [[IV]]
; CHECK-NEXT: [[EL:%.*]] = load i32, i32* [[EL_PTR]], align 4
; CHECK-NEXT: [[LOOP_COND:%.*]] = icmp eq i32 [[EL]], 0
; CHECK-NEXT: br i1 [[LOOP_COND]], label [[LOOP]], label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: ret void
; CHECK: fail:
; CHECK-NEXT: unreachable
;
preheader:
%len = load i32, i32* %p
%start = zext i32 %len to i64
br label %loop
loop:
%iv = phi i64 [%start, %preheader], [%iv.next, %backedge]
%zero_cond = icmp eq i64 %iv, 0
br i1 %zero_cond, label %exit, label %range_check_block
range_check_block:
%iv.next = sub i64 %iv, 1
%narrow = trunc i64 %iv.next to i32
%range_check = icmp uge i32 %narrow, %len
br i1 %range_check, label %fail, label %backedge
backedge:
%el.ptr = getelementptr i32, i32* %arr, i64 %iv
%el = load i32, i32* %el.ptr
%loop.cond = icmp eq i32 %el, 0
br i1 %loop.cond, label %loop, label %exit
exit:
ret void
fail:
unreachable
}
!0 = !{i32 0, i32 2147483647}