1 ; RUN: opt < %s -loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -instcombine -S | FileCheck %s
3 target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
5 ; CHECK-LABEL: @vector_gep_stored(
7 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ]
8 ; CHECK-NEXT: [[VEC_IND:%.*]] = phi <4 x i64> [ <i64 0, i64 1, i64 2, i64 3>, %vector.ph ], [ [[VEC_IND_NEXT:%.*]], %vector.body ]
9 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i32, i32* %b, <4 x i64> [[VEC_IND]]
10 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds i32*, i32** %a, i64 [[INDEX]]
11 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast i32** [[TMP2]] to <4 x i32*>*
12 ; CHECK-NEXT: store <4 x i32*> [[TMP1]], <4 x i32*>* [[TMP3]], align 8
13 ; CHECK-NEXT: [[INDEX_NEXT]] = add i64 [[INDEX]], 4
14 ; CHECK-NEXT: [[VEC_IND_NEXT]] = add <4 x i64> [[VEC_IND]], <i64 4, i64 4, i64 4, i64 4>
15 ; CHECK: br i1 {{.*}}, label %middle.block, label %vector.body
17 define void @vector_gep_stored(i32** %a, i32 *%b, i64 %n) {
22 %i = phi i64 [ %i.next, %for.body ], [ 0, %entry ]
23 %tmp0 = getelementptr inbounds i32, i32* %b, i64 %i
24 %tmp1 = getelementptr inbounds i32*, i32** %a, i64 %i
25 store i32* %tmp0, i32** %tmp1, align 8
26 %i.next = add nuw nsw i64 %i, 1
27 %cond = icmp slt i64 %i.next, %n
28 br i1 %cond, label %for.body, label %for.end
34 ; CHECK-LABEL: @uniform_vector_gep_stored(
36 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ]
37 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i32, i32* %b, i64 1
38 ; CHECK-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <4 x i32*> undef, i32* [[TMP1]], i32 0
39 ; CHECK-NEXT: [[DOTSPLAT:%.*]] = shufflevector <4 x i32*> [[DOTSPLATINSERT]], <4 x i32*> undef, <4 x i32> zeroinitializer
40 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds i32*, i32** %a, i64 [[INDEX]]
41 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast i32** [[TMP2]] to <4 x i32*>*
42 ; CHECK-NEXT: store <4 x i32*> [[DOTSPLAT]], <4 x i32*>* [[TMP3]], align 8
43 ; CHECK-NEXT: [[INDEX_NEXT]] = add i64 [[INDEX]], 4
44 ; CHECK: br i1 {{.*}}, label %middle.block, label %vector.body
46 define void @uniform_vector_gep_stored(i32** %a, i32 *%b, i64 %n) {
51 %i = phi i64 [ %i.next, %for.body ], [ 0, %entry ]
52 %tmp0 = getelementptr inbounds i32, i32* %b, i64 1
53 %tmp1 = getelementptr inbounds i32*, i32** %a, i64 %i
54 store i32* %tmp0, i32** %tmp1, align 8
55 %i.next = add nuw nsw i64 %i, 1
56 %cond = icmp slt i64 %i.next, %n
57 br i1 %cond, label %for.body, label %for.end