1 ; RUN: opt -cost-model -analyze -mtriple=amdgcn-unknown-amdhsa -mattr=+half-rate-64-ops < %s | FileCheck %s
2 ; RUN: opt -cost-model -analyze -mtriple=amdgcn-unknown-amdhsa -mattr=-half-rate-64-ops < %s | FileCheck %s
5 ; CHECK: estimated cost of 1 for {{.*}} add i32
6 define amdgpu_kernel void @add_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %vaddr, i32 %b) #0 {
7 %vec = load i32, i32 addrspace(1)* %vaddr
8 %add = add i32 %vec, %b
9 store i32 %add, i32 addrspace(1)* %out
14 ; CHECK: estimated cost of 2 for {{.*}} add <2 x i32>
15 define amdgpu_kernel void @add_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> addrspace(1)* %vaddr, <2 x i32> %b) #0 {
16 %vec = load <2 x i32>, <2 x i32> addrspace(1)* %vaddr
17 %add = add <2 x i32> %vec, %b
18 store <2 x i32> %add, <2 x i32> addrspace(1)* %out
23 ; Allow for 4 when v3i32 is illegal and TargetLowering thinks it needs widening,
24 ; and 3 when it is legal.
25 ; CHECK: estimated cost of {{[34]}} for {{.*}} add <3 x i32>
26 define amdgpu_kernel void @add_v3i32(<3 x i32> addrspace(1)* %out, <3 x i32> addrspace(1)* %vaddr, <3 x i32> %b) #0 {
27 %vec = load <3 x i32>, <3 x i32> addrspace(1)* %vaddr
28 %add = add <3 x i32> %vec, %b
29 store <3 x i32> %add, <3 x i32> addrspace(1)* %out
34 ; CHECK: estimated cost of 4 for {{.*}} add <4 x i32>
35 define amdgpu_kernel void @add_v4i32(<4 x i32> addrspace(1)* %out, <4 x i32> addrspace(1)* %vaddr, <4 x i32> %b) #0 {
36 %vec = load <4 x i32>, <4 x i32> addrspace(1)* %vaddr
37 %add = add <4 x i32> %vec, %b
38 store <4 x i32> %add, <4 x i32> addrspace(1)* %out
43 ; Allow for 8 when v3i32 is illegal and TargetLowering thinks it needs widening,
44 ; and 5 when it is legal.
45 ; CHECK: estimated cost of {{[58]}} for {{.*}} add <5 x i32>
46 define amdgpu_kernel void @add_v5i32(<5 x i32> addrspace(1)* %out, <5 x i32> addrspace(1)* %vaddr, <5 x i32> %b) #0 {
47 %vec = load <5 x i32>, <5 x i32> addrspace(1)* %vaddr
48 %add = add <5 x i32> %vec, %b
49 store <5 x i32> %add, <5 x i32> addrspace(1)* %out
54 ; CHECK: estimated cost of 2 for {{.*}} add i64
55 define amdgpu_kernel void @add_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %vaddr, i64 %b) #0 {
56 %vec = load i64, i64 addrspace(1)* %vaddr
57 %add = add i64 %vec, %b
58 store i64 %add, i64 addrspace(1)* %out
63 ; CHECK: estimated cost of 4 for {{.*}} add <2 x i64>
64 define amdgpu_kernel void @add_v2i64(<2 x i64> addrspace(1)* %out, <2 x i64> addrspace(1)* %vaddr, <2 x i64> %b) #0 {
65 %vec = load <2 x i64>, <2 x i64> addrspace(1)* %vaddr
66 %add = add <2 x i64> %vec, %b
67 store <2 x i64> %add, <2 x i64> addrspace(1)* %out
72 ; CHECK: estimated cost of 6 for {{.*}} add <3 x i64>
73 define amdgpu_kernel void @add_v3i64(<3 x i64> addrspace(1)* %out, <3 x i64> addrspace(1)* %vaddr, <3 x i64> %b) #0 {
74 %vec = load <3 x i64>, <3 x i64> addrspace(1)* %vaddr
75 %add = add <3 x i64> %vec, %b
76 store <3 x i64> %add, <3 x i64> addrspace(1)* %out
81 ; CHECK: estimated cost of 8 for {{.*}} add <4 x i64>
82 define amdgpu_kernel void @add_v4i64(<4 x i64> addrspace(1)* %out, <4 x i64> addrspace(1)* %vaddr, <4 x i64> %b) #0 {
83 %vec = load <4 x i64>, <4 x i64> addrspace(1)* %vaddr
84 %add = add <4 x i64> %vec, %b
85 store <4 x i64> %add, <4 x i64> addrspace(1)* %out
90 ; CHECK: estimated cost of 32 for {{.*}} add <16 x i64>
91 define amdgpu_kernel void @add_v16i64(<16 x i64> addrspace(1)* %out, <16 x i64> addrspace(1)* %vaddr, <16 x i64> %b) #0 {
92 %vec = load <16 x i64>, <16 x i64> addrspace(1)* %vaddr
93 %add = add <16 x i64> %vec, %b
94 store <16 x i64> %add, <16 x i64> addrspace(1)* %out
99 ; CHECK: estimated cost of 1 for {{.*}} add i16
100 define amdgpu_kernel void @add_i16(i16 addrspace(1)* %out, i16 addrspace(1)* %vaddr, i16 %b) #0 {
101 %vec = load i16, i16 addrspace(1)* %vaddr
102 %add = add i16 %vec, %b
103 store i16 %add, i16 addrspace(1)* %out
108 ; CHECK: estimated cost of 2 for {{.*}} add <2 x i16>
109 define amdgpu_kernel void @add_v2i16(<2 x i16> addrspace(1)* %out, <2 x i16> addrspace(1)* %vaddr, <2 x i16> %b) #0 {
110 %vec = load <2 x i16>, <2 x i16> addrspace(1)* %vaddr
111 %add = add <2 x i16> %vec, %b
112 store <2 x i16> %add, <2 x i16> addrspace(1)* %out
117 ; CHECK: estimated cost of 1 for {{.*}} sub i32
118 define amdgpu_kernel void @sub_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %vaddr, i32 %b) #0 {
119 %vec = load i32, i32 addrspace(1)* %vaddr
120 %sub = sub i32 %vec, %b
121 store i32 %sub, i32 addrspace(1)* %out
126 ; CHECK: estimated cost of 2 for {{.*}} sub i64
127 define amdgpu_kernel void @sub_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %vaddr, i64 %b) #0 {
128 %vec = load i64, i64 addrspace(1)* %vaddr
129 %sub = sub i64 %vec, %b
130 store i64 %sub, i64 addrspace(1)* %out
134 ; CHECK: estimated cost of 1 for {{.*}} sub i16
135 define amdgpu_kernel void @sub_i16(i16 addrspace(1)* %out, i16 addrspace(1)* %vaddr, i16 %b) #0 {
136 %vec = load i16, i16 addrspace(1)* %vaddr
137 %sub = sub i16 %vec, %b
138 store i16 %sub, i16 addrspace(1)* %out
143 ; CHECK: estimated cost of 2 for {{.*}} sub <2 x i16>
144 define amdgpu_kernel void @sub_v2i16(<2 x i16> addrspace(1)* %out, <2 x i16> addrspace(1)* %vaddr, <2 x i16> %b) #0 {
145 %vec = load <2 x i16>, <2 x i16> addrspace(1)* %vaddr
146 %sub = sub <2 x i16> %vec, %b
147 store <2 x i16> %sub, <2 x i16> addrspace(1)* %out
151 attributes #0 = { nounwind }