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