xref: /llvm-project/llvm/test/Transforms/LoopVectorize/ARM/interleaved_cost.ll (revision c8c0b18b5d58415b79ea13b62eee70c130c26a0a)
1; RUN: opt -passes=loop-vectorize -force-vector-width=2 -debug-only=loop-vectorize -disable-output < %s 2>&1 | FileCheck %s --check-prefix=VF_2
2; RUN: opt -passes=loop-vectorize -force-vector-width=4 -debug-only=loop-vectorize -disable-output < %s 2>&1 | FileCheck %s --check-prefix=VF_4
3; RUN: opt -passes=loop-vectorize -force-vector-width=8 -debug-only=loop-vectorize -disable-output < %s 2>&1 | FileCheck %s --check-prefix=VF_8
4; RUN: opt -passes=loop-vectorize -force-vector-width=16 -debug-only=loop-vectorize -disable-output < %s 2>&1 | FileCheck %s --check-prefix=VF_16
5; REQUIRES: asserts
6
7target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
8target triple = "armv8--linux-gnueabihf"
9
10%i8.2 = type {i8, i8}
11define void @i8_factor_2(ptr %data, i64 %n) {
12entry:
13  br label %for.body
14
15; VF_8-LABEL:  Checking a loop in 'i8_factor_2'
16; VF_8:          Found an estimated cost of 2 for VF 8 For instruction: %tmp2 = load i8, ptr %tmp0, align 1
17; VF_8-NEXT:     Found an estimated cost of 0 for VF 8 For instruction: %tmp3 = load i8, ptr %tmp1, align 1
18; VF_8-NEXT:     Found an estimated cost of 0 for VF 8 For instruction: store i8 %tmp2, ptr %tmp0, align 1
19; VF_8-NEXT:     Found an estimated cost of 2 for VF 8 For instruction: store i8 %tmp3, ptr %tmp1, align 1
20; VF_16-LABEL: Checking a loop in 'i8_factor_2'
21; VF_16:         Found an estimated cost of 2 for VF 16 For instruction: %tmp2 = load i8, ptr %tmp0, align 1
22; VF_16-NEXT:    Found an estimated cost of 0 for VF 16 For instruction: %tmp3 = load i8, ptr %tmp1, align 1
23; VF_16-NEXT:    Found an estimated cost of 0 for VF 16 For instruction: store i8 %tmp2, ptr %tmp0, align 1
24; VF_16-NEXT:    Found an estimated cost of 2 for VF 16 For instruction: store i8 %tmp3, ptr %tmp1, align 1
25for.body:
26  %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
27  %tmp0 = getelementptr inbounds %i8.2, ptr %data, i64 %i, i32 0
28  %tmp1 = getelementptr inbounds %i8.2, ptr %data, i64 %i, i32 1
29  %tmp2 = load i8, ptr %tmp0, align 1
30  %tmp3 = load i8, ptr %tmp1, align 1
31  store i8 %tmp2, ptr %tmp0, align 1
32  store i8 %tmp3, ptr %tmp1, align 1
33  %i.next = add nuw nsw i64 %i, 1
34  %cond = icmp slt i64 %i.next, %n
35  br i1 %cond, label %for.body, label %for.end
36
37for.end:
38  ret void
39}
40
41%i16.2 = type {i16, i16}
42define void @i16_factor_2(ptr %data, i64 %n) {
43entry:
44  br label %for.body
45
46; VF_4-LABEL:  Checking a loop in 'i16_factor_2'
47; VF_4:          Found an estimated cost of 2 for VF 4 For instruction: %tmp2 = load i16, ptr %tmp0, align 2
48; VF_4-NEXT:     Found an estimated cost of 0 for VF 4 For instruction: %tmp3 = load i16, ptr %tmp1, align 2
49; VF_4-NEXT:     Found an estimated cost of 0 for VF 4 For instruction: store i16 %tmp2, ptr %tmp0, align 2
50; VF_4-NEXT:     Found an estimated cost of 2 for VF 4 For instruction: store i16 %tmp3, ptr %tmp1, align 2
51; VF_8-LABEL:  Checking a loop in 'i16_factor_2'
52; VF_8:          Found an estimated cost of 2 for VF 8 For instruction: %tmp2 = load i16, ptr %tmp0, align 2
53; VF_8-NEXT:     Found an estimated cost of 0 for VF 8 For instruction: %tmp3 = load i16, ptr %tmp1, align 2
54; VF_8-NEXT:     Found an estimated cost of 0 for VF 8 For instruction: store i16 %tmp2, ptr %tmp0, align 2
55; VF_8-NEXT:     Found an estimated cost of 2 for VF 8 For instruction: store i16 %tmp3, ptr %tmp1, align 2
56; VF_16-LABEL: Checking a loop in 'i16_factor_2'
57; VF_16:         Found an estimated cost of 4 for VF 16 For instruction: %tmp2 = load i16, ptr %tmp0, align 2
58; VF_16-NEXT:    Found an estimated cost of 0 for VF 16 For instruction: %tmp3 = load i16, ptr %tmp1, align 2
59; VF_16-NEXT:    Found an estimated cost of 0 for VF 16 For instruction: store i16 %tmp2, ptr %tmp0, align 2
60; VF_16-NEXT:    Found an estimated cost of 4 for VF 16 For instruction: store i16 %tmp3, ptr %tmp1, align 2
61for.body:
62  %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
63  %tmp0 = getelementptr inbounds %i16.2, ptr %data, i64 %i, i32 0
64  %tmp1 = getelementptr inbounds %i16.2, ptr %data, i64 %i, i32 1
65  %tmp2 = load i16, ptr %tmp0, align 2
66  %tmp3 = load i16, ptr %tmp1, align 2
67  store i16 %tmp2, ptr %tmp0, align 2
68  store i16 %tmp3, ptr %tmp1, align 2
69  %i.next = add nuw nsw i64 %i, 1
70  %cond = icmp slt i64 %i.next, %n
71  br i1 %cond, label %for.body, label %for.end
72
73for.end:
74  ret void
75}
76
77%i32.2 = type {i32, i32}
78define void @i32_factor_2(ptr %data, i64 %n) {
79entry:
80  br label %for.body
81
82; VF_2-LABEL:  Checking a loop in 'i32_factor_2'
83; VF_2:          Found an estimated cost of 2 for VF 2 For instruction: %tmp2 = load i32, ptr %tmp0, align 4
84; VF_2-NEXT:     Found an estimated cost of 0 for VF 2 For instruction: %tmp3 = load i32, ptr %tmp1, align 4
85; VF_2-NEXT:     Found an estimated cost of 0 for VF 2 For instruction: store i32 %tmp2, ptr %tmp0, align 4
86; VF_2-NEXT:     Found an estimated cost of 2 for VF 2 For instruction: store i32 %tmp3, ptr %tmp1, align 4
87; VF_4-LABEL:  Checking a loop in 'i32_factor_2'
88; VF_4:          Found an estimated cost of 2 for VF 4 For instruction: %tmp2 = load i32, ptr %tmp0, align 4
89; VF_4-NEXT:     Found an estimated cost of 0 for VF 4 For instruction: %tmp3 = load i32, ptr %tmp1, align 4
90; VF_4-NEXT:     Found an estimated cost of 0 for VF 4 For instruction: store i32 %tmp2, ptr %tmp0, align 4
91; VF_4-NEXT:     Found an estimated cost of 2 for VF 4 For instruction: store i32 %tmp3, ptr %tmp1, align 4
92; VF_8-LABEL:  Checking a loop in 'i32_factor_2'
93; VF_8:          Found an estimated cost of 4 for VF 8 For instruction: %tmp2 = load i32, ptr %tmp0, align 4
94; VF_8-NEXT:     Found an estimated cost of 0 for VF 8 For instruction: %tmp3 = load i32, ptr %tmp1, align 4
95; VF_8-NEXT:     Found an estimated cost of 0 for VF 8 For instruction: store i32 %tmp2, ptr %tmp0, align 4
96; VF_8-NEXT:     Found an estimated cost of 4 for VF 8 For instruction: store i32 %tmp3, ptr %tmp1, align 4
97; VF_16-LABEL: Checking a loop in 'i32_factor_2'
98; VF_16:         Found an estimated cost of 8 for VF 16 For instruction: %tmp2 = load i32, ptr %tmp0, align 4
99; VF_16-NEXT:    Found an estimated cost of 0 for VF 16 For instruction: %tmp3 = load i32, ptr %tmp1, align 4
100; VF_16-NEXT:    Found an estimated cost of 0 for VF 16 For instruction: store i32 %tmp2, ptr %tmp0, align 4
101; VF_16-NEXT:    Found an estimated cost of 8 for VF 16 For instruction: store i32 %tmp3, ptr %tmp1, align 4
102for.body:
103  %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
104  %tmp0 = getelementptr inbounds %i32.2, ptr %data, i64 %i, i32 0
105  %tmp1 = getelementptr inbounds %i32.2, ptr %data, i64 %i, i32 1
106  %tmp2 = load i32, ptr %tmp0, align 4
107  %tmp3 = load i32, ptr %tmp1, align 4
108  store i32 %tmp2, ptr %tmp0, align 4
109  store i32 %tmp3, ptr %tmp1, align 4
110  %i.next = add nuw nsw i64 %i, 1
111  %cond = icmp slt i64 %i.next, %n
112  br i1 %cond, label %for.body, label %for.end
113
114for.end:
115  ret void
116}
117
118%half.2 = type {half, half}
119define void @half_factor_2(ptr %data, i64 %n) {
120entry:
121  br label %for.body
122
123; VF_4-LABEL: Checking a loop in 'half_factor_2'
124; VF_4:         Found an estimated cost of 40 for VF 4 For instruction: %tmp2 = load half, ptr %tmp0, align 2
125; VF_4-NEXT:    Found an estimated cost of 0 for VF 4 For instruction: %tmp3 = load half, ptr %tmp1, align 2
126; VF_4-NEXT:    Found an estimated cost of 0 for VF 4 For instruction: store half %tmp2, ptr %tmp0, align 2
127; VF_4-NEXT:    Found an estimated cost of 40 for VF 4 For instruction: store half %tmp3, ptr %tmp1, align 2
128; VF_8-LABEL: Checking a loop in 'half_factor_2'
129; VF_8:         Found an estimated cost of 80 for VF 8 For instruction: %tmp2 = load half, ptr %tmp0, align 2
130; VF_8-NEXT:    Found an estimated cost of 0 for VF 8 For instruction: %tmp3 = load half, ptr %tmp1, align 2
131; VF_8-NEXT:    Found an estimated cost of 0 for VF 8 For instruction: store half %tmp2, ptr %tmp0, align 2
132; VF_8-NEXT:    Found an estimated cost of 80 for VF 8 For instruction: store half %tmp3, ptr %tmp1, align 2
133for.body:
134  %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
135  %tmp0 = getelementptr inbounds %half.2, ptr %data, i64 %i, i32 0
136  %tmp1 = getelementptr inbounds %half.2, ptr %data, i64 %i, i32 1
137  %tmp2 = load half, ptr %tmp0, align 2
138  %tmp3 = load half, ptr %tmp1, align 2
139  store half %tmp2, ptr %tmp0, align 2
140  store half %tmp3, ptr %tmp1, align 2
141  %i.next = add nuw nsw i64 %i, 1
142  %cond = icmp slt i64 %i.next, %n
143  br i1 %cond, label %for.body, label %for.end
144
145for.end:
146  ret void
147}
148