2 ; RUN: opt < %s -passes='function(loop-vectorize,instcombine)' -force-vector-width=2 -force-vector-interleave=1 -debug-only=loop-vectorize -disable-output -print-after=instcombine 2>&1 | FileCheck %s
4 target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
6 ; CHECK-LABEL: phi_two_incoming_values
7 ; CHECK: LV: Found an estimated cost of 1 for VF 2 For instruction: %i = phi i64 [ %i.next, %if.end ], [ 0, %entry ]
8 ; CHECK: LV: Found an estimated cost of 1 for VF 2 For instruction: %tmp5 = phi i32 [ %tmp1, %for.body ], [ %tmp4, %if.then ]
9 ; CHECK: define void @phi_two_incoming_values(
11 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ]
12 ; CHECK: [[WIDE_LOAD:%.*]] = load <2 x i32>, ptr {{.*}}
13 ; CHECK: [[TMP5:%.*]] = icmp sgt <2 x i32> [[WIDE_LOAD]], zeroinitializer
14 ; CHECK-NEXT: [[TMP6:%.*]] = zext <2 x i1> [[TMP5]] to <2 x i32>
15 ; CHECK-NEXT: [[PREDPHI:%.*]] = add <2 x i32> [[WIDE_LOAD]], [[TMP6]]
16 ; CHECK: store <2 x i32> [[PREDPHI]], ptr {{.*}}
17 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 2
19 define void @phi_two_incoming_values(ptr %a, ptr %b, i64 %n) {
24 %i = phi i64 [ %i.next, %if.end ], [ 0, %entry ]
25 %tmp0 = getelementptr inbounds i32, ptr %a, i64 %i
26 %tmp1 = load i32, ptr %tmp0, align 4
27 %tmp2 = getelementptr inbounds i32, ptr %b, i64 %i
28 %tmp3 = icmp sgt i32 %tmp1, 0
29 br i1 %tmp3, label %if.then, label %if.end
32 %tmp4 = add i32 %tmp1, 1
36 %tmp5 = phi i32 [ %tmp1, %for.body ], [ %tmp4, %if.then ]
37 store i32 %tmp5, ptr %tmp2, align 4
38 %i.next = add i64 %i, 1
39 %cond = icmp eq i64 %i, %n
40 br i1 %cond, label %for.end, label %for.body
46 ; CHECK-LABEL: phi_three_incoming_values
47 ; CHECK: LV: Found an estimated cost of 1 for VF 2 For instruction: %i = phi i64 [ %i.next, %if.end ], [ 0, %entry ]
48 ; CHECK: LV: Found an estimated cost of 2 for VF 2 For instruction: %tmp8 = phi i32 [ 9, %for.body ], [ 3, %if.then ], [ %tmp7, %if.else ]
49 ; CHECK: define void @phi_three_incoming_values(
51 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ]
52 ; CHECK: [[PREDPHI:%.*]] = select <2 x i1> {{.*}}, <2 x i32> <i32 3, i32 3>, <2 x i32> <i32 9, i32 9>
53 ; CHECK: [[PREDPHI7:%.*]] = select <2 x i1> {{.*}}, <2 x i32> {{.*}}, <2 x i32> [[PREDPHI]]
54 ; CHECK: store <2 x i32> [[PREDPHI7]], ptr {{.*}}
55 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 2
57 define void @phi_three_incoming_values(ptr %a, ptr %b, i64 %n) {
62 %i = phi i64 [ %i.next, %if.end ], [ 0, %entry ]
63 %tmp0 = getelementptr inbounds i32, ptr %a, i64 %i
64 %tmp1 = load i32, ptr %tmp0, align 4
65 %tmp2 = getelementptr inbounds i32, ptr %b, i64 %i
66 %tmp3 = load i32, ptr %tmp2, align 4
67 %tmp4 = icmp sgt i32 %tmp1, %tmp3
68 br i1 %tmp4, label %if.then, label %if.end
71 %tmp5 = icmp sgt i32 %tmp1, 19
72 br i1 %tmp5, label %if.end, label %if.else
75 %tmp6 = icmp slt i32 %tmp3, 4
76 %tmp7 = select i1 %tmp6, i32 4, i32 5
80 %tmp8 = phi i32 [ 9, %for.body ], [ 3, %if.then ], [ %tmp7, %if.else ]
81 store i32 %tmp8, ptr %tmp0, align 4
82 %i.next = add i64 %i, 1
83 %cond = icmp eq i64 %i, %n
84 br i1 %cond, label %for.end, label %for.body