1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -passes='print<scalar-evolution>' -disable-output %s 2>&1 | FileCheck %s
4 define void @loop_guard_improves_exact_backedge_taken_count_1(i32 %conv) {
5 ; CHECK-LABEL: 'loop_guard_improves_exact_backedge_taken_count_1'
6 ; CHECK-NEXT: Classifying expressions for: @loop_guard_improves_exact_backedge_taken_count_1
7 ; CHECK-NEXT: %and = and i32 %conv, 1
8 ; CHECK-NEXT: --> (zext i1 (trunc i32 %conv to i1) to i32) U: [0,2) S: [0,2)
9 ; CHECK-NEXT: %conv8 = zext i32 %and to i64
10 ; CHECK-NEXT: --> (zext i1 (trunc i32 %conv to i1) to i64) U: [0,2) S: [0,2)
11 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
12 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,1) S: [0,1) Exits: 0 LoopDispositions: { %loop: Computable }
13 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
14 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,2) S: [1,2) Exits: 1 LoopDispositions: { %loop: Computable }
15 ; CHECK-NEXT: Determining loop execution counts for: @loop_guard_improves_exact_backedge_taken_count_1
16 ; CHECK-NEXT: Loop %loop: backedge-taken count is 0
17 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 0
18 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is 0
19 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is 0
20 ; CHECK-NEXT: Predicates:
21 ; CHECK: Loop %loop: Trip multiple is 1
24 %and = and i32 %conv, 1
25 %conv8 = zext i32 %and to i64
26 %c = icmp ugt i32 %and, 0
27 br i1 %c, label %exit, label %loop
30 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
32 %iv.next = add i64 %iv, 1
33 %exitcond = icmp eq i64 %iv, %conv8
34 br i1 %exitcond, label %exit, label %loop
40 define void @loop_guard_improves_exact_backedge_taken_count_2(i32 %conv) {
41 ; CHECK-LABEL: 'loop_guard_improves_exact_backedge_taken_count_2'
42 ; CHECK-NEXT: Classifying expressions for: @loop_guard_improves_exact_backedge_taken_count_2
43 ; CHECK-NEXT: %and = and i32 %conv, 1
44 ; CHECK-NEXT: --> (zext i1 (trunc i32 %conv to i1) to i32) U: [0,2) S: [0,2)
45 ; CHECK-NEXT: %conv8 = zext i32 %and to i64
46 ; CHECK-NEXT: --> (zext i1 (trunc i32 %conv to i1) to i64) U: [0,2) S: [0,2)
47 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
48 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,2) S: [0,2) Exits: (zext i1 (trunc i32 %conv to i1) to i64) LoopDispositions: { %loop: Computable }
49 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
50 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,3) S: [1,3) Exits: (1 + (zext i1 (trunc i32 %conv to i1) to i64))<nuw><nsw> LoopDispositions: { %loop: Computable }
51 ; CHECK-NEXT: Determining loop execution counts for: @loop_guard_improves_exact_backedge_taken_count_2
52 ; CHECK-NEXT: Loop %loop: backedge-taken count is (zext i1 (trunc i32 %conv to i1) to i64)
53 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 1
54 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (zext i1 (trunc i32 %conv to i1) to i64)
55 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (zext i1 (trunc i32 %conv to i1) to i64)
56 ; CHECK-NEXT: Predicates:
57 ; CHECK: Loop %loop: Trip multiple is 2
60 %and = and i32 %conv, 1
61 %conv8 = zext i32 %and to i64
62 %c = icmp eq i32 %and, 1
63 br i1 %c, label %loop, label %exit
66 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
68 %iv.next = add i64 %iv, 1
69 %exitcond = icmp eq i64 %iv, %conv8
70 br i1 %exitcond, label %exit, label %loop
76 declare void @clobber()