1 ; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s
3 define void @merge_values_with_ranges(i32 *%a_len_ptr, i32 *%b_len_ptr, i1 %unknown_cond) {
5 ; CHECK-LABEL: Classifying expressions for: @merge_values_with_ranges
6 ; CHECK: %len = phi i32 [ %len_a, %if.true ], [ %len_b, %if.false ]
7 ; CHECK-NEXT: --> %len U: [0,2147483647) S: [0,2147483647)
10 br i1 %unknown_cond, label %if.true, label %if.false
13 %len_a = load i32, i32* %a_len_ptr, !range !0
17 %len_b = load i32, i32* %b_len_ptr, !range !0
21 %len = phi i32 [ %len_a, %if.true ], [ %len_b, %if.false ]
25 define void @merge_values_with_ranges_looped(i32 *%a_len_ptr, i32 *%b_len_ptr) {
27 ; TODO: We could be much smarter here. So far we just make sure that we do not
28 ; go into infinite loop analyzing these Phis.
30 ; CHECK-LABEL: Classifying expressions for: @merge_values_with_ranges_looped
31 ; CHECK: %p1 = phi i32 [ %len_a, %entry ], [ %p2, %loop ]
32 ; CHECK-NEXT: --> %p1 U: full-set S: full-set
33 ; CHECK: %p2 = phi i32 [ %len_b, %entry ], [ %p1, %loop ]
34 ; CHECK-NEXT: --> %p2 U: full-set S: full-set
37 %len_a = load i32, i32* %a_len_ptr, !range !0
38 %len_b = load i32, i32* %b_len_ptr, !range !0
42 %p1 = phi i32 [ %len_a, %entry ], [ %p2, %loop ]
43 %p2 = phi i32 [ %len_b, %entry ], [ %p1, %loop ]
44 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
45 %iv.next = add i32 %iv, 1
46 %loop.cond = icmp slt i32 %iv.next, 100
47 br i1 %loop.cond, label %loop, label %exit
54 !0 = !{i32 0, i32 2147483647}