Skip to content

Commit 2a41d70

Browse files
committed
[SCEV] Add tests with signed predicates for applyLoopGuards.
1 parent 7648b69 commit 2a41d70

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info.ll

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,3 +1104,111 @@ while.end.loopexit:
11041104
while.end:
11051105
ret void
11061106
}
1107+
1108+
define void @test_guard_slt_sgt_1(i32* nocapture %a, i64 %N) {
1109+
; CHECK-LABEL: 'test_guard_slt_sgt_1'
1110+
; CHECK: Determining loop execution counts for: @test_guard_slt_sgt
1111+
; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + %N)
1112+
; CHECK-NEXT: Loop %loop: max backedge-taken count is -2
1113+
; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-1 + %N)
1114+
; CHECK-NEXT: Predicates:
1115+
; CHECK: Loop %loop: Trip multiple is 1
1116+
;
1117+
entry:
1118+
%c.0 = icmp slt i64 %N, 12
1119+
%c.1 = icmp sgt i64 %N, 0
1120+
%and = and i1 %c.0, %c.1
1121+
br i1 %and, label %loop, label %exit
1122+
1123+
loop:
1124+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
1125+
%idx = getelementptr inbounds i32, i32* %a, i64 %iv
1126+
store i32 1, i32* %idx, align 4
1127+
%iv.next = add nuw nsw i64 %iv, 1
1128+
%exitcond = icmp eq i64 %iv.next, %N
1129+
br i1 %exitcond, label %exit, label %loop
1130+
1131+
exit:
1132+
ret void
1133+
}
1134+
1135+
define void @test_guard_slt_sgt_2(i32* nocapture %a, i64 %i) {
1136+
; CHECK-LABEL: 'test_guard_slt_sgt_2'
1137+
; CHECK: Determining loop execution counts for: @test_guard_slt_sgt
1138+
; CHECK-NEXT: Loop %loop: backedge-taken count is (17 + (-1 * %i))
1139+
; CHECK-NEXT: Loop %loop: max backedge-taken count is -1
1140+
; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (17 + (-1 * %i))
1141+
; CHECK-NEXT: Predicates:
1142+
; CHECK: Loop %loop: Trip multiple is 1
1143+
;
1144+
entry:
1145+
%c.0 = icmp slt i64 %i, 16
1146+
%c.1 = icmp sgt i64 %i, 4
1147+
%and = and i1 %c.0, %c.1
1148+
br i1 %and, label %loop, label %exit
1149+
1150+
loop:
1151+
%iv = phi i64 [ %iv.next, %loop ], [ %i, %entry ]
1152+
%idx = getelementptr inbounds i32, i32* %a, i64 %iv
1153+
store i32 1, i32* %idx, align 4
1154+
%iv.next = add nuw nsw i64 %iv, 1
1155+
%exitcond = icmp eq i64 %iv.next, 18
1156+
br i1 %exitcond, label %exit, label %loop
1157+
1158+
exit:
1159+
ret void
1160+
}
1161+
1162+
define void @test_guard_sle_sge_1(i32* nocapture %a, i64 %N) {
1163+
; CHECK-LABEL: 'test_guard_sle_sge_1'
1164+
; CHECK: Determining loop execution counts for: @test_guard_sle_sge_1
1165+
; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + %N)
1166+
; CHECK-NEXT: Loop %loop: max backedge-taken count is -2
1167+
; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-1 + %N)
1168+
; CHECK-NEXT: Predicates:
1169+
; CHECK: Loop %loop: Trip multiple is 1
1170+
;
1171+
entry:
1172+
%c.0 = icmp sle i64 %N, 12
1173+
%c.1 = icmp sge i64 %N, 1
1174+
%and = and i1 %c.0, %c.1
1175+
br i1 %and, label %loop, label %exit
1176+
1177+
loop:
1178+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
1179+
%idx = getelementptr inbounds i32, i32* %a, i64 %iv
1180+
store i32 1, i32* %idx, align 4
1181+
%iv.next = add nuw nsw i64 %iv, 1
1182+
%exitcond = icmp eq i64 %iv.next, %N
1183+
br i1 %exitcond, label %exit, label %loop
1184+
1185+
exit:
1186+
ret void
1187+
}
1188+
1189+
define void @test_guard_sle_sge_2(i32* nocapture %a, i64 %i) {
1190+
; CHECK-LABEL: 'test_guard_sle_sge_2'
1191+
; CHECK: Determining loop execution counts for: @test_guard_sle_sge
1192+
; CHECK-NEXT: Loop %loop: backedge-taken count is (17 + (-1 * %i))
1193+
; CHECK-NEXT: Loop %loop: max backedge-taken count is -1
1194+
; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (17 + (-1 * %i))
1195+
; CHECK-NEXT: Predicates:
1196+
; CHECK: Loop %loop: Trip multiple is 1
1197+
;
1198+
entry:
1199+
%c.0 = icmp sle i64 %i, 16
1200+
%c.1 = icmp sge i64 %i, 4
1201+
%and = and i1 %c.0, %c.1
1202+
br i1 %and, label %loop, label %exit
1203+
1204+
loop:
1205+
%iv = phi i64 [ %iv.next, %loop ], [ %i, %entry ]
1206+
%idx = getelementptr inbounds i32, i32* %a, i64 %iv
1207+
store i32 1, i32* %idx, align 4
1208+
%iv.next = add nuw nsw i64 %iv, 1
1209+
%exitcond = icmp eq i64 %iv.next, 18
1210+
br i1 %exitcond, label %exit, label %loop
1211+
1212+
exit:
1213+
ret void
1214+
}

0 commit comments

Comments
 (0)