xref: /llvm-project/llvm/test/Transforms/LoopIdiom/memcpy-vectors.ll (revision 055fb7795aa219a3d274d280ec9129784f169f56)
1; RUN: opt -passes=loop-idiom -S <%s | FileCheck %s
2
3define void @memcpy_fixed_vec(ptr noalias %a, ptr noalias %b) local_unnamed_addr #1 {
4; CHECK-LABEL: @memcpy_fixed_vec(
5; CHECK: entry:
6; CHECK: memcpy
7; CHECK: vector.body
8entry:
9  br label %vector.body
10
11vector.body:                                      ; preds = %vector.body, %entry
12  %index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
13  %0 = getelementptr inbounds i64, ptr %a, i64 %index
14  %wide.load = load <2 x i64>, ptr %0, align 8
15  %1 = getelementptr inbounds i64, ptr %b, i64 %index
16  store <2 x i64> %wide.load, ptr %1, align 8
17  %index.next = add nuw nsw i64 %index, 2
18  %2 = icmp eq i64 %index.next, 1024
19  br i1 %2, label %for.cond.cleanup, label %vector.body
20
21for.cond.cleanup:                                 ; preds = %vector.body
22  ret void
23}
24
25define void @memcpy_scalable_vec(ptr noalias %a, ptr noalias %b) local_unnamed_addr #1 {
26; CHECK-LABEL: @memcpy_scalable_vec(
27; CHECK: entry:
28; CHECK-NOT: memcpy
29; CHECK: vector.body
30entry:
31  br label %vector.body
32
33vector.body:                                      ; preds = %vector.body, %entry
34  %index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
35  %0 = getelementptr inbounds <vscale x 2 x i64>, ptr %a, i64 %index
36  %wide.load = load <vscale x 2 x i64>, ptr %0, align 16
37  %1 = getelementptr inbounds <vscale x 2 x i64>, ptr %b, i64 %index
38  store <vscale x 2 x i64> %wide.load, ptr %1, align 16
39  %index.next = add nuw nsw i64 %index, 1
40  %2 = icmp eq i64 %index.next, 1024
41  br i1 %2, label %for.cond.cleanup, label %vector.body
42
43for.cond.cleanup:                                 ; preds = %vector.body
44  ret void
45}
46