brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.0 KiB · c3a1943 Raw
100 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 %s --check-prefix=DEFAULT3; RUN: opt -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-use-expensive-range-sharpening < %s 2>&1 | FileCheck %s  --check-prefix=EXPENSIVE_SHARPENING4 5; This test exercises the following scenario:6; given: n > 07; for (i = 0, j = n - 1; i < n; i++, j--) {8;   a = n - i;9;   b = (n - 1) - i;10;   c = 2147483647 - 1;11; }12;13; Note that value ranges of 'i' and 'j' are the same, just inverted. It means that14; they have same ranges and same no-wrap properties. 'b' is just an alternative15; way to compute the same value as 'j'. 'a' is effectively 'j + 1' and 'c' is a16; a positive value. All involved addrecs for 'i', 'j', 'a', 'b', 'c' should have17; no-sign-wrap flag.18;19;        i's AddRec is expected to be proven no-sign-wrap20;        j's AddRec is expected to be proven no-sign-wrap21; FIXME: a's AddRec is expected to be no-sign-wrap22;        b's AddRec is expected to be no-sign-wrap23; FIXME: c's AddRec is expected to be no-sign-wrap24;        i is expected to be non-negative25;        j is expected to be non-negative26;        a is expected to be positive27;        b is expected to be non-negative28;        c is expected to be positive29define i32 @test_step_1_flags(i32 %n) {30; DEFAULT-LABEL: 'test_step_1_flags'31; DEFAULT-NEXT:  Classifying expressions for: @test_step_1_flags32; DEFAULT-NEXT:    %n.minus.1 = sub nsw i32 %n, 133; DEFAULT-NEXT:    --> (-1 + %n) U: full-set S: full-set34; DEFAULT-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]35; DEFAULT-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,2147483647) S: [0,2147483647) Exits: (-1 + %n) LoopDispositions: { %loop: Computable }36; DEFAULT-NEXT:    %j = phi i32 [ %n.minus.1, %entry ], [ %j.next, %loop ]37; DEFAULT-NEXT:    --> {(-1 + %n),+,-1}<nsw><%loop> U: full-set S: full-set Exits: 0 LoopDispositions: { %loop: Computable }38; DEFAULT-NEXT:    %a = sub i32 %n, %i39; DEFAULT-NEXT:    --> {%n,+,-1}<nw><%loop> U: full-set S: full-set Exits: 1 LoopDispositions: { %loop: Computable }40; DEFAULT-NEXT:    %b = sub i32 %n.minus.1, %i41; DEFAULT-NEXT:    --> {(-1 + %n),+,-1}<nsw><%loop> U: full-set S: full-set Exits: 0 LoopDispositions: { %loop: Computable }42; DEFAULT-NEXT:    %c = sub i32 2147483647, %i43; DEFAULT-NEXT:    --> {2147483647,+,-1}<nsw><%loop> U: [1,-2147483648) S: [1,-2147483648) Exits: (-2147483648 + (-1 * %n)) LoopDispositions: { %loop: Computable }44; DEFAULT-NEXT:    %i.next = add nuw nsw i32 %i, 145; DEFAULT-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,-2147483648) S: [1,-2147483648) Exits: %n LoopDispositions: { %loop: Computable }46; DEFAULT-NEXT:    %j.next = add nsw i32 %j, -147; DEFAULT-NEXT:    --> {(-2 + %n),+,-1}<nw><%loop> U: full-set S: full-set Exits: -1 LoopDispositions: { %loop: Computable }48; DEFAULT-NEXT:  Determining loop execution counts for: @test_step_1_flags49; DEFAULT-NEXT:  Loop %loop: backedge-taken count is (-1 + %n)50; DEFAULT-NEXT:  Loop %loop: constant max backedge-taken count is i32 214748364651; DEFAULT-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %n)52; DEFAULT-NEXT:  Loop %loop: Trip multiple is 153;54; EXPENSIVE_SHARPENING-LABEL: 'test_step_1_flags'55; EXPENSIVE_SHARPENING-NEXT:  Classifying expressions for: @test_step_1_flags56; EXPENSIVE_SHARPENING-NEXT:    %n.minus.1 = sub nsw i32 %n, 157; EXPENSIVE_SHARPENING-NEXT:    --> (-1 + %n) U: full-set S: full-set58; EXPENSIVE_SHARPENING-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]59; EXPENSIVE_SHARPENING-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,2147483647) S: [0,2147483647) Exits: (-1 + %n) LoopDispositions: { %loop: Computable }60; EXPENSIVE_SHARPENING-NEXT:    %j = phi i32 [ %n.minus.1, %entry ], [ %j.next, %loop ]61; EXPENSIVE_SHARPENING-NEXT:    --> {(-1 + %n),+,-1}<nsw><%loop> U: [0,2147483647) S: [0,2147483647) Exits: 0 LoopDispositions: { %loop: Computable }62; EXPENSIVE_SHARPENING-NEXT:    %a = sub i32 %n, %i63; EXPENSIVE_SHARPENING-NEXT:    --> {%n,+,-1}<nw><%loop> U: [1,-2147483648) S: [1,-2147483648) Exits: 1 LoopDispositions: { %loop: Computable }64; EXPENSIVE_SHARPENING-NEXT:    %b = sub i32 %n.minus.1, %i65; EXPENSIVE_SHARPENING-NEXT:    --> {(-1 + %n),+,-1}<nsw><%loop> U: [0,2147483647) S: [0,2147483647) Exits: 0 LoopDispositions: { %loop: Computable }66; EXPENSIVE_SHARPENING-NEXT:    %c = sub i32 2147483647, %i67; EXPENSIVE_SHARPENING-NEXT:    --> {2147483647,+,-1}<nsw><%loop> U: [1,-2147483648) S: [1,-2147483648) Exits: (-2147483648 + (-1 * %n)) LoopDispositions: { %loop: Computable }68; EXPENSIVE_SHARPENING-NEXT:    %i.next = add nuw nsw i32 %i, 169; EXPENSIVE_SHARPENING-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,-2147483648) S: [1,-2147483648) Exits: %n LoopDispositions: { %loop: Computable }70; EXPENSIVE_SHARPENING-NEXT:    %j.next = add nsw i32 %j, -171; EXPENSIVE_SHARPENING-NEXT:    --> {(-2 + %n),+,-1}<nsw><%loop> U: full-set S: [-1,2147483646) Exits: -1 LoopDispositions: { %loop: Computable }72; EXPENSIVE_SHARPENING-NEXT:  Determining loop execution counts for: @test_step_1_flags73; EXPENSIVE_SHARPENING-NEXT:  Loop %loop: backedge-taken count is (-1 + %n)74; EXPENSIVE_SHARPENING-NEXT:  Loop %loop: constant max backedge-taken count is i32 214748364675; EXPENSIVE_SHARPENING-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %n)76; EXPENSIVE_SHARPENING-NEXT:  Loop %loop: Trip multiple is 177;78entry:79  %n.minus.1 = sub nsw i32 %n, 180  %precond = icmp sgt i32 %n, 081  br i1 %precond, label %loop, label %fail82 83loop:84  %i = phi i32 [0, %entry], [%i.next, %loop]                      ; 0...n-185  %j = phi i32 [%n.minus.1, %entry], [%j.next, %loop]             ; n-1...086  %a = sub i32 %n, %i                                             ; n...187  %b = sub i32 %n.minus.1, %i                                     ; n-1...088  %c = sub i32 2147483647, %i                                     ; 2147483647...189  %i.next = add nuw nsw i32 %i, 190  %j.next = add nsw i32 %j, -191  %cond = icmp slt i32 %i.next, %n92  br i1 %cond, label %loop, label %exit93 94fail:95  ret i32 -196 97exit:98  ret i32 099}100