75 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 22; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s3 4define i32 @test_1_non_negative(i32 %n) {5; CHECK-LABEL: 'test_1_non_negative'6; CHECK-NEXT: Classifying expressions for: @test_1_non_negative7; CHECK-NEXT: %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]8; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,2147483647) S: [0,2147483647) Exits: (-1 + (1 smax %n))<nsw> LoopDispositions: { %loop: Computable }9; CHECK-NEXT: %a = sub i32 %n, %i10; CHECK-NEXT: --> {%n,+,-1}<nw><%loop> U: full-set S: full-set Exits: (1 + (-1 * (1 smax %n))<nsw> + %n) LoopDispositions: { %loop: Computable }11; CHECK-NEXT: %i.next = add nuw nsw i32 %i, 112; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,-2147483648) S: [1,-2147483648) Exits: (1 smax %n) LoopDispositions: { %loop: Computable }13; CHECK-NEXT: Determining loop execution counts for: @test_1_non_negative14; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + (1 smax %n))<nsw>15; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 214748364616; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-1 + (1 smax %n))<nsw>17; CHECK-NEXT: Loop %loop: Trip multiple is 118;19entry:20 %precond = icmp sge i32 %n, 021 br i1 %precond, label %loop, label %fail22 23loop:24 %i = phi i32 [0, %entry], [%i.next, %loop] ; 0...n-125 %a = sub i32 %n, %i ; n...026 %i.next = add nuw nsw i32 %i, 127 %cond = icmp slt i32 %i.next, %n28 br i1 %cond, label %loop, label %exit29 30fail:31 ret i32 -132 33exit:34 ret i32 035}36 37define i32 @test_2_non_positive(i32 %n) {38; CHECK-LABEL: 'test_2_non_positive'39; CHECK-NEXT: Classifying expressions for: @test_2_non_positive40; CHECK-NEXT: %minus.n = mul i32 %n, -141; CHECK-NEXT: --> (-1 * %n) U: full-set S: full-set42; CHECK-NEXT: %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]43; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,2147483647) S: [0,2147483647) Exits: (-1 + (1 smax %n))<nsw> LoopDispositions: { %loop: Computable }44; CHECK-NEXT: %minus.i = mul i32 %i, -145; CHECK-NEXT: --> {0,+,-1}<nsw><%loop> U: [-2147483646,1) S: [-2147483646,1) Exits: (1 + (-1 * (1 smax %n))<nsw>)<nsw> LoopDispositions: { %loop: Computable }46; CHECK-NEXT: %a = sub i32 %minus.n, %minus.i47; CHECK-NEXT: --> {(-1 * %n),+,1}<nw><%loop> U: full-set S: full-set Exits: (-1 + (-1 * %n) + (1 smax %n)) LoopDispositions: { %loop: Computable }48; CHECK-NEXT: %i.next = add nuw nsw i32 %i, 149; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,-2147483648) S: [1,-2147483648) Exits: (1 smax %n) LoopDispositions: { %loop: Computable }50; CHECK-NEXT: Determining loop execution counts for: @test_2_non_positive51; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + (1 smax %n))<nsw>52; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 214748364653; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-1 + (1 smax %n))<nsw>54; CHECK-NEXT: Loop %loop: Trip multiple is 155;56entry:57 %precond = icmp sge i32 %n, 058 %minus.n = mul i32 %n, -159 br i1 %precond, label %loop, label %fail60 61loop:62 %i = phi i32 [0, %entry], [%i.next, %loop] ; 0...n-163 %minus.i = mul i32 %i, -1 ; -(n-1)...064 %a = sub i32 %minus.n, %minus.i ; -n...-165 %i.next = add nuw nsw i32 %i, 166 %cond = icmp slt i32 %i.next, %n67 br i1 %cond, label %loop, label %exit68 69fail:70 ret i32 -171 72exit:73 ret i32 074}75