1 ;RUN: opt < %s -passes=loop-vectorize,instcombine -force-vector-width=4 -force-vector-interleave=1 -S | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 ;; Check consecutive memory access without preceding GEP instruction
7 ; for (int i=0; i<len; i++) {
11 ; CHECK-LABEL: @consecutive_no_gep(
13 ; CHECK: %[[index:.*]] = phi i64 [ 0, %vector.ph ]
14 ; CHECK: %[[offset:.*]] = shl i64 %[[index]], 2
15 ; CHECK: getelementptr i8, ptr %{{.*}}, i64 %[[offset]]
16 ; CHECK: load <4 x float>
18 define void @consecutive_no_gep(ptr noalias nocapture readonly %from, ptr noalias nocapture %to, i32 %len) #0 {
20 %cmp2 = icmp sgt i32 %len, 0
21 br i1 %cmp2, label %for.body.preheader, label %for.end
23 for.body.preheader: ; preds = %entry
26 for.body: ; preds = %for.body.preheader, %for.body
27 %i.05 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
28 %from.addr.04 = phi ptr [ %incdec.ptr, %for.body ], [ %from, %for.body.preheader ]
29 %to.addr.03 = phi ptr [ %incdec.ptr1, %for.body ], [ %to, %for.body.preheader ]
30 %incdec.ptr = getelementptr inbounds float, ptr %from.addr.04, i64 1
31 %val = load float, ptr %from.addr.04, align 4
32 %incdec.ptr1 = getelementptr inbounds float, ptr %to.addr.03, i64 1
33 store float %val, ptr %to.addr.03, align 4
34 %inc = add nsw i32 %i.05, 1
35 %cmp = icmp slt i32 %inc, %len
36 br i1 %cmp, label %for.body, label %for.end.loopexit
38 for.end.loopexit: ; preds = %for.body
41 for.end: ; preds = %for.end.loopexit, %entry