blob: b1ec8795192ed3f487e4bf39664b81c238a9d044 [file] [log] [blame]
Roman Lebedevd68a2772019-08-12 09:24:33 +00001; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
Fangrui Song7979f242020-10-31 22:29:57 -08002; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -cost-kind=throughput -analyze | FileCheck %s --check-prefix=THROUGHPUT
3; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -cost-kind=latency -analyze | FileCheck %s --check-prefix=LATENCY
4; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -cost-kind=code-size -analyze | FileCheck %s --check-prefix=CODESIZE
Roman Lebedevd68a2772019-08-12 09:24:33 +00005
6define i32 @extract_first_i32({i32, i32} %agg) {
Roman Lebedev31ba61b2019-08-12 17:45:12 +00007; THROUGHPUT-LABEL: 'extract_first_i32'
Roman Lebedevcc95a452019-08-29 11:50:30 +00008; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 0
Roman Lebedev31ba61b2019-08-12 17:45:12 +00009; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %r
10;
11; LATENCY-LABEL: 'extract_first_i32'
Roman Lebedevcc95a452019-08-29 11:50:30 +000012; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 0
Roman Lebedev31ba61b2019-08-12 17:45:12 +000013; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r
14;
15; CODESIZE-LABEL: 'extract_first_i32'
Roman Lebedevcc95a452019-08-29 11:50:30 +000016; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 0
Roman Lebedev31ba61b2019-08-12 17:45:12 +000017; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r
Roman Lebedevd68a2772019-08-12 09:24:33 +000018;
19 %r = extractvalue {i32, i32} %agg, 0
20 ret i32 %r
21}
22
23define i32 @extract_second_i32({i32, i32} %agg) {
Roman Lebedev31ba61b2019-08-12 17:45:12 +000024; THROUGHPUT-LABEL: 'extract_second_i32'
Roman Lebedevcc95a452019-08-29 11:50:30 +000025; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 1
Roman Lebedev31ba61b2019-08-12 17:45:12 +000026; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %r
27;
28; LATENCY-LABEL: 'extract_second_i32'
Roman Lebedevcc95a452019-08-29 11:50:30 +000029; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 1
Roman Lebedev31ba61b2019-08-12 17:45:12 +000030; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r
31;
32; CODESIZE-LABEL: 'extract_second_i32'
Roman Lebedevcc95a452019-08-29 11:50:30 +000033; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 1
Roman Lebedev31ba61b2019-08-12 17:45:12 +000034; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r
Roman Lebedevd68a2772019-08-12 09:24:33 +000035;
36 %r = extractvalue {i32, i32} %agg, 1
37 ret i32 %r
38}
39
40define i32 @extract_i32({i32, i1} %agg) {
Roman Lebedev31ba61b2019-08-12 17:45:12 +000041; THROUGHPUT-LABEL: 'extract_i32'
Roman Lebedevcc95a452019-08-29 11:50:30 +000042; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 0
Roman Lebedev31ba61b2019-08-12 17:45:12 +000043; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %r
44;
45; LATENCY-LABEL: 'extract_i32'
Roman Lebedevcc95a452019-08-29 11:50:30 +000046; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 0
Roman Lebedev31ba61b2019-08-12 17:45:12 +000047; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r
48;
49; CODESIZE-LABEL: 'extract_i32'
Roman Lebedevcc95a452019-08-29 11:50:30 +000050; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 0
Roman Lebedev31ba61b2019-08-12 17:45:12 +000051; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r
Roman Lebedevd68a2772019-08-12 09:24:33 +000052;
53 %r = extractvalue {i32, i1} %agg, 0
54 ret i32 %r
55}
56
57define i1 @extract_i1({i32, i1} %agg) {
Roman Lebedev31ba61b2019-08-12 17:45:12 +000058; THROUGHPUT-LABEL: 'extract_i1'
Roman Lebedevcc95a452019-08-29 11:50:30 +000059; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 1
Roman Lebedev31ba61b2019-08-12 17:45:12 +000060; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i1 %r
61;
62; LATENCY-LABEL: 'extract_i1'
Roman Lebedevcc95a452019-08-29 11:50:30 +000063; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 1
Roman Lebedev31ba61b2019-08-12 17:45:12 +000064; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i1 %r
65;
66; CODESIZE-LABEL: 'extract_i1'
Roman Lebedevcc95a452019-08-29 11:50:30 +000067; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 1
Roman Lebedev31ba61b2019-08-12 17:45:12 +000068; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i1 %r
Roman Lebedevd68a2772019-08-12 09:24:33 +000069;
70 %r = extractvalue {i32, i1} %agg, 1
71 ret i1 %r
72}
73
74define float @extract_float({i32, float} %agg) {
Roman Lebedev31ba61b2019-08-12 17:45:12 +000075; THROUGHPUT-LABEL: 'extract_float'
Roman Lebedevcc95a452019-08-29 11:50:30 +000076; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, float } %agg, 1
Roman Lebedev31ba61b2019-08-12 17:45:12 +000077; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret float %r
78;
79; LATENCY-LABEL: 'extract_float'
Roman Lebedevcc95a452019-08-29 11:50:30 +000080; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, float } %agg, 1
Roman Lebedev31ba61b2019-08-12 17:45:12 +000081; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret float %r
82;
83; CODESIZE-LABEL: 'extract_float'
Roman Lebedevcc95a452019-08-29 11:50:30 +000084; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, float } %agg, 1
Roman Lebedev31ba61b2019-08-12 17:45:12 +000085; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret float %r
Roman Lebedevd68a2772019-08-12 09:24:33 +000086;
87 %r = extractvalue {i32, float} %agg, 1
88 ret float %r
89}
90
91define [42 x i42] @extract_array({i32, [42 x i42]} %agg) {
Roman Lebedev31ba61b2019-08-12 17:45:12 +000092; THROUGHPUT-LABEL: 'extract_array'
Roman Lebedevcc95a452019-08-29 11:50:30 +000093; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, [42 x i42] } %agg, 1
Roman Lebedev31ba61b2019-08-12 17:45:12 +000094; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret [42 x i42] %r
95;
96; LATENCY-LABEL: 'extract_array'
Roman Lebedevcc95a452019-08-29 11:50:30 +000097; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, [42 x i42] } %agg, 1
Roman Lebedev31ba61b2019-08-12 17:45:12 +000098; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret [42 x i42] %r
99;
100; CODESIZE-LABEL: 'extract_array'
Roman Lebedevcc95a452019-08-29 11:50:30 +0000101; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, [42 x i42] } %agg, 1
Roman Lebedev31ba61b2019-08-12 17:45:12 +0000102; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret [42 x i42] %r
Roman Lebedevd68a2772019-08-12 09:24:33 +0000103;
104 %r = extractvalue {i32, [42 x i42]} %agg, 1
105 ret [42 x i42] %r
106}
107
108define <42 x i42> @extract_vector({i32, <42 x i42>} %agg) {
Roman Lebedev31ba61b2019-08-12 17:45:12 +0000109; THROUGHPUT-LABEL: 'extract_vector'
Roman Lebedevcc95a452019-08-29 11:50:30 +0000110; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, <42 x i42> } %agg, 1
Roman Lebedev31ba61b2019-08-12 17:45:12 +0000111; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <42 x i42> %r
112;
113; LATENCY-LABEL: 'extract_vector'
Roman Lebedevcc95a452019-08-29 11:50:30 +0000114; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, <42 x i42> } %agg, 1
Roman Lebedev31ba61b2019-08-12 17:45:12 +0000115; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret <42 x i42> %r
116;
117; CODESIZE-LABEL: 'extract_vector'
Roman Lebedevcc95a452019-08-29 11:50:30 +0000118; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, <42 x i42> } %agg, 1
Roman Lebedev31ba61b2019-08-12 17:45:12 +0000119; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret <42 x i42> %r
Roman Lebedevd68a2772019-08-12 09:24:33 +0000120;
121 %r = extractvalue {i32, <42 x i42>} %agg, 1
122 ret <42 x i42> %r
123}
124
125%T1 = type { i32, float, <4 x i1> }
126
127define %T1 @extract_struct({i32, %T1} %agg) {
Roman Lebedev31ba61b2019-08-12 17:45:12 +0000128; THROUGHPUT-LABEL: 'extract_struct'
Roman Lebedevcc95a452019-08-29 11:50:30 +0000129; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, %T1 } %agg, 1
Roman Lebedev31ba61b2019-08-12 17:45:12 +0000130; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret %T1 %r
131;
132; LATENCY-LABEL: 'extract_struct'
Roman Lebedevcc95a452019-08-29 11:50:30 +0000133; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, %T1 } %agg, 1
Roman Lebedev31ba61b2019-08-12 17:45:12 +0000134; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret %T1 %r
135;
136; CODESIZE-LABEL: 'extract_struct'
Roman Lebedevcc95a452019-08-29 11:50:30 +0000137; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, %T1 } %agg, 1
Roman Lebedev31ba61b2019-08-12 17:45:12 +0000138; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret %T1 %r
Roman Lebedevd68a2772019-08-12 09:24:33 +0000139;
140 %r = extractvalue {i32, %T1} %agg, 1
141 ret %T1 %r
142}