xref: /llvm-project/llvm/test/Analysis/CostModel/AArch64/aggregates.ll (revision 75f1b328f8fb2468e8bef618b022ad8ce928097d)
1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2; RUN: opt < %s -mtriple=aarch64-unknown-linux-gnu -passes="print<cost-model>" -cost-kind=throughput 2>&1 -disable-output | FileCheck %s --check-prefix=THROUGHPUT
3; RUN: opt < %s -mtriple=aarch64-unknown-linux-gnu -passes="print<cost-model>" -cost-kind=latency 2>&1 -disable-output | FileCheck %s --check-prefix=LATENCY
4; RUN: opt < %s -mtriple=aarch64-unknown-linux-gnu -passes="print<cost-model>" -cost-kind=code-size 2>&1 -disable-output | FileCheck %s --check-prefix=CODESIZE
5
6target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
7
8define i32 @extract_first_i32({i32, i32} %agg) {
9; THROUGHPUT-LABEL: 'extract_first_i32'
10; THROUGHPUT-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 0
11; THROUGHPUT-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i32 %r
12;
13; LATENCY-LABEL: 'extract_first_i32'
14; LATENCY-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 0
15; LATENCY-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r
16;
17; CODESIZE-LABEL: 'extract_first_i32'
18; CODESIZE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 0
19; CODESIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r
20;
21  %r = extractvalue {i32, i32} %agg, 0
22  ret i32 %r
23}
24
25define i32 @extract_second_i32({i32, i32} %agg) {
26; THROUGHPUT-LABEL: 'extract_second_i32'
27; THROUGHPUT-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 1
28; THROUGHPUT-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i32 %r
29;
30; LATENCY-LABEL: 'extract_second_i32'
31; LATENCY-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 1
32; LATENCY-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r
33;
34; CODESIZE-LABEL: 'extract_second_i32'
35; CODESIZE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 1
36; CODESIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r
37;
38  %r = extractvalue {i32, i32} %agg, 1
39  ret i32 %r
40}
41
42define i32 @extract_i32({i32, i1} %agg) {
43; THROUGHPUT-LABEL: 'extract_i32'
44; THROUGHPUT-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 0
45; THROUGHPUT-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i32 %r
46;
47; LATENCY-LABEL: 'extract_i32'
48; LATENCY-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 0
49; LATENCY-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r
50;
51; CODESIZE-LABEL: 'extract_i32'
52; CODESIZE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 0
53; CODESIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r
54;
55  %r = extractvalue {i32, i1} %agg, 0
56  ret i32 %r
57}
58
59define i1 @extract_i1({i32, i1} %agg) {
60; THROUGHPUT-LABEL: 'extract_i1'
61; THROUGHPUT-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 1
62; THROUGHPUT-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i1 %r
63;
64; LATENCY-LABEL: 'extract_i1'
65; LATENCY-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 1
66; LATENCY-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret i1 %r
67;
68; CODESIZE-LABEL: 'extract_i1'
69; CODESIZE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 1
70; CODESIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret i1 %r
71;
72  %r = extractvalue {i32, i1} %agg, 1
73  ret i1 %r
74}
75
76define float @extract_float({i32, float} %agg) {
77; THROUGHPUT-LABEL: 'extract_float'
78; THROUGHPUT-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, float } %agg, 1
79; THROUGHPUT-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret float %r
80;
81; LATENCY-LABEL: 'extract_float'
82; LATENCY-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, float } %agg, 1
83; LATENCY-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret float %r
84;
85; CODESIZE-LABEL: 'extract_float'
86; CODESIZE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, float } %agg, 1
87; CODESIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret float %r
88;
89  %r = extractvalue {i32, float} %agg, 1
90  ret float %r
91}
92
93define [42 x i42] @extract_array({i32, [42 x i42]} %agg) {
94; THROUGHPUT-LABEL: 'extract_array'
95; THROUGHPUT-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, [42 x i42] } %agg, 1
96; THROUGHPUT-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret [42 x i42] %r
97;
98; LATENCY-LABEL: 'extract_array'
99; LATENCY-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, [42 x i42] } %agg, 1
100; LATENCY-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret [42 x i42] %r
101;
102; CODESIZE-LABEL: 'extract_array'
103; CODESIZE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, [42 x i42] } %agg, 1
104; CODESIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret [42 x i42] %r
105;
106  %r = extractvalue {i32, [42 x i42]} %agg, 1
107  ret [42 x i42] %r
108}
109
110define <42 x i42> @extract_vector({i32, <42 x i42>} %agg) {
111; THROUGHPUT-LABEL: 'extract_vector'
112; THROUGHPUT-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, <42 x i42> } %agg, 1
113; THROUGHPUT-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <42 x i42> %r
114;
115; LATENCY-LABEL: 'extract_vector'
116; LATENCY-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, <42 x i42> } %agg, 1
117; LATENCY-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret <42 x i42> %r
118;
119; CODESIZE-LABEL: 'extract_vector'
120; CODESIZE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, <42 x i42> } %agg, 1
121; CODESIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret <42 x i42> %r
122;
123  %r = extractvalue {i32, <42 x i42>} %agg, 1
124  ret <42 x i42> %r
125}
126
127%T1 = type { i32, float, <4 x i1> }
128
129define %T1 @extract_struct({i32, %T1} %agg) {
130; THROUGHPUT-LABEL: 'extract_struct'
131; THROUGHPUT-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, %T1 } %agg, 1
132; THROUGHPUT-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret %T1 %r
133;
134; LATENCY-LABEL: 'extract_struct'
135; LATENCY-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, %T1 } %agg, 1
136; LATENCY-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret %T1 %r
137;
138; CODESIZE-LABEL: 'extract_struct'
139; CODESIZE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, %T1 } %agg, 1
140; CODESIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret %T1 %r
141;
142  %r = extractvalue {i32, %T1} %agg, 1
143  ret %T1 %r
144}
145