1 ; RUN: opt -passes=loop-vectorize -mtriple=x86_64-unknown-linux -force-vector-width=2 -force-vector-interleave=1 -S %s | FileCheck %s
3 define ptr @test(ptr noalias %src, ptr noalias %dst) {
7 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], [[PRED_LOAD_CONTINUE2:%.*]] ]
8 ; CHECK-NEXT: [[VEC_IND:%.*]] = phi <2 x i64> [ <i64 0, i64 1>, %vector.ph ], [ [[VEC_IND_NEXT:%.*]], [[PRED_LOAD_CONTINUE2]] ]
9 ; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[INDEX]], 0
10 ; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[INDEX]], 1
11 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds i32, ptr [[SRC:%.*]], i64 [[TMP1]]
12 ; CHECK-NEXT: [[TMP3:%.*]] = icmp eq <2 x i64> [[VEC_IND]], zeroinitializer
13 ; CHECK-NEXT: [[TMP4:%.*]] = xor <2 x i1> [[TMP3]], <i1 true, i1 true>
14 ; CHECK-NEXT: [[TMP5:%.*]] = extractelement <2 x i1> [[TMP4]], i32 0
15 ; CHECK-NEXT: br i1 [[TMP5]], label [[PRED_LOAD_IF:%.*]], label [[PRED_LOAD_CONTINUE:%.*]]
16 ; CHECK: pred.load.if:
17 ; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds i32, ptr [[SRC]], i64 [[TMP0]]
18 ; CHECK-NEXT: [[TMP7:%.*]] = load i32, ptr [[TMP6]], align 4
19 ; CHECK-NEXT: [[TMP8:%.*]] = insertelement <2 x i32> poison, i32 [[TMP7]], i32 0
20 ; CHECK-NEXT: br label [[PRED_LOAD_CONTINUE]]
21 ; CHECK: pred.load.continue:
22 ; CHECK-NEXT: [[TMP9:%.*]] = phi <2 x i32> [ poison, %vector.body ], [ [[TMP8]], [[PRED_LOAD_IF]] ]
23 ; CHECK-NEXT: [[TMP10:%.*]] = extractelement <2 x i1> [[TMP4]], i32 1
24 ; CHECK-NEXT: br i1 [[TMP10]], label [[PRED_LOAD_IF1:%.*]], label [[PRED_LOAD_CONTINUE2]]
25 ; CHECK: pred.load.if1:
26 ; CHECK-NEXT: [[TMP11:%.*]] = load i32, ptr [[TMP2]], align 4
27 ; CHECK-NEXT: [[TMP12:%.*]] = insertelement <2 x i32> [[TMP9]], i32 [[TMP11]], i32 1
28 ; CHECK-NEXT: br label [[PRED_LOAD_CONTINUE2]]
29 ; CHECK: pred.load.continue2:
30 ; CHECK-NEXT: [[TMP13:%.*]] = phi <2 x i32> [ [[TMP9]], [[PRED_LOAD_CONTINUE]] ], [ [[TMP12]], [[PRED_LOAD_IF1]] ]
31 ; CHECK-NEXT: [[PREDPHI:%.*]] = select <2 x i1> [[TMP3]], <2 x i32> zeroinitializer, <2 x i32> [[TMP13]]
32 ; CHECK-NEXT: [[TMP14:%.*]] = getelementptr inbounds i32, ptr [[DST:%.*]], i64 [[TMP0]]
33 ; CHECK-NEXT: [[TMP15:%.*]] = getelementptr inbounds i32, ptr [[TMP14]], i32 0
34 ; CHECK-NEXT: store <2 x i32> [[PREDPHI]], ptr [[TMP15]], align 4
35 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 2
36 ; CHECK-NEXT: [[VEC_IND_NEXT]] = add <2 x i64> [[VEC_IND]], <i64 2, i64 2>
37 ; CHECK-NEXT: [[TMP17:%.*]] = icmp eq i64 [[INDEX_NEXT]], 1000
38 ; CHECK-NEXT: br i1 [[TMP17]], label [[MIDDLE_BLOCK:%.*]], label %vector.body
39 ; CHECK: middle.block:
40 ; CHECK-NEXT: br i1 true, label %exit, label %scalar.ph
42 ; CHECK-NEXT: [[GEP_LCSSA:%.*]] = phi ptr [ %gep.src, %loop.latch ], [ [[TMP2]], %middle.block ]
43 ; CHECK-NEXT: ret ptr [[GEP_LCSSA]]
49 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]
50 %gep.src = getelementptr inbounds i32, ptr %src, i64 %iv
51 %cmp.1 = icmp eq i64 %iv, 0
52 br i1 %cmp.1, label %loop.latch, label %then
55 %l = load i32, ptr %gep.src, align 4
59 %m = phi i32 [ %l, %then ], [ 0, %loop.header ]
60 %gep.dst = getelementptr inbounds i32, ptr %dst, i64 %iv
61 store i32 %m, ptr %gep.dst, align 4
62 %iv.next = add nsw i64 %iv, 1
63 %cmp.2 = icmp slt i64 %iv.next, 1000
64 br i1 %cmp.2, label %loop.header, label %exit
67 %gep.lcssa = phi ptr [ %gep.src, %loop.latch ]