1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py 2; RUN: opt -analyze -scalar-evolution < %s | FileCheck %s 3 4; The semanics of this example are a bit subtle. The loop is required 5; execute some number of times up to 1999. The compiler is free to reduce 6; the number of said iterations to zero (or any value in between) if desired, 7; but if it does so, the return value and the last value stored to G must 8; agree. For SCEV, this translates as widenable conditions preventing exact 9; exit counts from being computed, but not restricting max exit counts. 10; It's tempting to say that SCEV should return a precise exit count here, but 11; would result in miscompiles if transformations such as RLEV ran before 12; widening of the WC. 13define i32 @wc_max() { 14; CHECK-LABEL: 'wc_max' 15; CHECK-NEXT: Classifying expressions for: @wc_max 16; CHECK-NEXT: %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ] 17; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,2000) S: [0,2000) Exits: <<Unknown>> LoopDispositions: { %loop: Computable } 18; CHECK-NEXT: %iv.next = add i32 %iv, 1 19; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,2001) S: [1,2001) Exits: <<Unknown>> LoopDispositions: { %loop: Computable } 20; CHECK-NEXT: %widenable_cond3 = call i1 @llvm.experimental.widenable.condition() 21; CHECK-NEXT: --> %widenable_cond3 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant } 22; CHECK-NEXT: %exiplicit_guard_cond4 = and i1 %cond_1, %widenable_cond3 23; CHECK-NEXT: --> %exiplicit_guard_cond4 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant } 24; CHECK-NEXT: Determining loop execution counts for: @wc_max 25; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count. 26; CHECK-NEXT: Loop %loop: max backedge-taken count is 1999 27; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count. 28; 29entry: 30 br label %loop 31loop: 32 %iv = phi i32 [0, %entry], [%iv.next, %loop] 33 %iv.next = add i32 %iv, 1 34 store i32 %iv, i32 *@G 35 %cond_1 = icmp slt i32 %iv.next, 2000 36 %widenable_cond3 = call i1 @llvm.experimental.widenable.condition() 37 %exiplicit_guard_cond4 = and i1 %cond_1, %widenable_cond3 38 br i1 %exiplicit_guard_cond4, label %loop, label %exit 39 40exit: 41 ret i32 %iv 42} 43 44@G = external global i32 45declare i1 @llvm.experimental.widenable.condition() 46