1 ; RUN: opt -loop-vectorize -dce -instcombine -S -force-vector-width=4 < %s 2>%t | FileCheck %s
3 define void @inv_store_last_lane(i32* noalias nocapture %a, i32* noalias nocapture %inv, i32* noalias nocapture readonly %b, i64 %n) {
4 ; CHECK-LABEL: @inv_store_last_lane
6 ; CHECK: store <4 x i32> %[[VEC_VAL:.*]], <
8 ; CHECK: %{{.*}} = extractelement <4 x i32> %[[VEC_VAL]], i32 3
13 for.body: ; preds = %entry, %for.body
14 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
15 %arrayidx = getelementptr inbounds i32, i32* %b, i64 %indvars.iv
16 %0 = load i32, i32* %arrayidx, align 4
17 %mul = shl nsw i32 %0, 1
18 %arrayidx2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
19 store i32 %mul, i32* %arrayidx2, align 4
20 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
21 %exitcond.not = icmp eq i64 %indvars.iv.next, %n
22 br i1 %exitcond.not, label %exit, label %for.body
24 exit: ; preds = %for.body
25 %arrayidx5 = getelementptr inbounds i32, i32* %inv, i64 42
26 store i32 %mul, i32* %arrayidx5, align 4
30 define float @ret_last_lane(float* noalias nocapture %a, float* noalias nocapture readonly %b, i64 %n) {
31 ; CHECK-LABEL: @ret_last_lane
33 ; CHECK: store <4 x float> %[[VEC_VAL:.*]], <
34 ; CHECK: middle.block:
35 ; CHECK: %{{.*}} = extractelement <4 x float> %[[VEC_VAL]], i32 3
40 for.body: ; preds = %for.body.preheader, %for.body
41 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
42 %arrayidx = getelementptr inbounds float, float* %b, i64 %indvars.iv
43 %0 = load float, float* %arrayidx, align 4
44 %mul = fmul float %0, 2.000000e+00
45 %arrayidx2 = getelementptr inbounds float, float* %a, i64 %indvars.iv
46 store float %mul, float* %arrayidx2, align 4
47 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
48 %exitcond.not = icmp eq i64 %indvars.iv.next, %n
49 br i1 %exitcond.not, label %exit, label %for.body
51 exit: ; preds = %for.body, %entry