1; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s 2 3define void @merge_values_with_ranges(i32 *%a_len_ptr, i32 *%b_len_ptr, i1 %unknown_cond) { 4 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) 8 9 entry: 10 br i1 %unknown_cond, label %if.true, label %if.false 11 12if.true: 13 %len_a = load i32, i32* %a_len_ptr, !range !0 14 br label %merge 15 16if.false: 17 %len_b = load i32, i32* %b_len_ptr, !range !0 18 br label %merge 19 20merge: 21 %len = phi i32 [ %len_a, %if.true ], [ %len_b, %if.false ] 22 ret void 23} 24 25define void @merge_values_with_ranges_looped(i32 *%a_len_ptr, i32 *%b_len_ptr) { 26 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. 29 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 35 36 entry: 37 %len_a = load i32, i32* %a_len_ptr, !range !0 38 %len_b = load i32, i32* %b_len_ptr, !range !0 39 br label %loop 40 41loop: 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 48 49exit: 50 ret void 51} 52 53 54!0 = !{i32 0, i32 2147483647} 55