xref: /llvm-project/llvm/test/Transforms/LoopVectorize/as_cast.ll (revision 83d9aa27680b6a7f3556fcf13ada70b4be95bab2)
1*83d9aa27SPietro Ghiglio; RUN: opt -passes=loop-vectorize %s -force-vector-width=1 -force-vector-interleave=2 -S -o - | FileCheck %s
2*83d9aa27SPietro Ghiglio
3*83d9aa27SPietro Ghigliodefine void @foo(ptr addrspace(1) %in) {
4*83d9aa27SPietro Ghiglioentry:
5*83d9aa27SPietro Ghiglio  br label %loop
6*83d9aa27SPietro Ghiglio
7*83d9aa27SPietro Ghiglioloop:
8*83d9aa27SPietro Ghiglio  %iter = phi i64 [ %next, %loop ], [ 0, %entry ]
9*83d9aa27SPietro Ghiglio  %ascast = addrspacecast ptr addrspace(1) %in to ptr
10*83d9aa27SPietro Ghiglio  %next = add i64 %iter, 1
11*83d9aa27SPietro Ghiglio  %arrayidx = getelementptr inbounds i64, ptr %ascast, i64 %next
12*83d9aa27SPietro Ghiglio  store i64 %next, ptr %arrayidx, align 4
13*83d9aa27SPietro Ghiglio
14*83d9aa27SPietro Ghiglio; check that we find the two interleaved blocks with ascast, gep and store:
15*83d9aa27SPietro Ghiglio; CHECK: pred.store.if:
16*83d9aa27SPietro Ghiglio; CHECK: [[ID1:%.*]] = add i64 %{{.*}}, 1
17*83d9aa27SPietro Ghiglio; CHECK: [[AS1:%.*]] = addrspacecast ptr addrspace(1) %{{.*}} to ptr
18*83d9aa27SPietro Ghiglio; CHECK: [[GEP1:%.*]] = getelementptr inbounds i64, ptr [[AS1]], i64 [[ID1]]
19*83d9aa27SPietro Ghiglio; CHECK: store i64 [[ID1]], ptr [[GEP1]]
20*83d9aa27SPietro Ghiglio
21*83d9aa27SPietro Ghiglio; CHECK: pred.store.if1:
22*83d9aa27SPietro Ghiglio; CHECK: [[ID2:%.*]] = add i64 %{{.*}}, 1
23*83d9aa27SPietro Ghiglio; CHECK: [[AS2:%.*]] = addrspacecast ptr addrspace(1) %in to ptr
24*83d9aa27SPietro Ghiglio; CHECK: [[GEP2:%.*]] = getelementptr inbounds i64, ptr [[AS2]], i64 [[ID2]]
25*83d9aa27SPietro Ghiglio; CHECK: store i64 [[ID2]], ptr %9, align 4
26*83d9aa27SPietro Ghiglio
27*83d9aa27SPietro Ghiglio  %cmp = icmp eq i64 %next, 7
28*83d9aa27SPietro Ghiglio  br i1 %cmp, label %exit, label %loop
29*83d9aa27SPietro Ghiglio
30*83d9aa27SPietro Ghiglio; check that we branch to the exit block
31*83d9aa27SPietro Ghiglio; CHECK: middle.block:
32*83d9aa27SPietro Ghiglio; CHECK: br i1 true, label %exit, label %scalar.ph
33*83d9aa27SPietro Ghiglio
34*83d9aa27SPietro Ghiglioexit:
35*83d9aa27SPietro Ghiglio  ret void
36*83d9aa27SPietro Ghiglio; CHECK: exit:
37*83d9aa27SPietro Ghiglio; CHECK:   ret void
38*83d9aa27SPietro Ghiglio}
39*83d9aa27SPietro Ghiglio
40*83d9aa27SPietro Ghiglio; CHECK: !{{[0-9]*}} = !{!"llvm.loop.isvectorized", i32 1}
41