• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
2
3; Make sure the add and load are reduced to 32-bits even with the
4; bitcast to vector.
5; GCN-LABEL: {{^}}bitcast_int_to_vector_extract_0:
6; GCN-DAG: s_load_dword [[B:s[0-9]+]]
7; GCN-DAG: buffer_load_dword [[A:v[0-9]+]]
8; GCN: v_add_i32_e32 [[ADD:v[0-9]+]], vcc, [[B]], [[A]]
9; GCN: buffer_store_dword [[ADD]]
10define void @bitcast_int_to_vector_extract_0(i32 addrspace(1)* %out, i64 addrspace(1)* %in, i64 %b) {
11   %a = load i64, i64 addrspace(1)* %in
12   %add = add i64 %a, %b
13   %val.bc = bitcast i64 %add to <2 x i32>
14   %extract = extractelement <2 x i32> %val.bc, i32 0
15   store i32 %extract, i32 addrspace(1)* %out
16   ret void
17}
18
19; GCN-LABEL: {{^}}bitcast_fp_to_vector_extract_0:
20; GCN: buffer_load_dwordx2
21; GCN: v_add_f64
22; GCN: buffer_store_dword v
23define void @bitcast_fp_to_vector_extract_0(i32 addrspace(1)* %out, double addrspace(1)* %in, double %b) {
24   %a = load double, double addrspace(1)* %in
25   %add = fadd double %a, %b
26   %val.bc = bitcast double %add to <2 x i32>
27   %extract = extractelement <2 x i32> %val.bc, i32 0
28   store i32 %extract, i32 addrspace(1)* %out
29   ret void
30}
31
32; GCN-LABEL: {{^}}bitcast_int_to_fpvector_extract_0:
33; GCN: buffer_load_dwordx2
34; GCN: v_add_i32
35; GCN: buffer_store_dword
36define void @bitcast_int_to_fpvector_extract_0(float addrspace(1)* %out, i64 addrspace(1)* %in, i64 %b) {
37   %a = load i64, i64 addrspace(1)* %in
38   %add = add i64 %a, %b
39   %val.bc = bitcast i64 %add to <2 x float>
40   %extract = extractelement <2 x float> %val.bc, i32 0
41   store float %extract, float addrspace(1)* %out
42   ret void
43}
44
45; GCN-LABEL: {{^}}no_extract_volatile_load_extract0:
46; GCN: buffer_load_dwordx4
47; GCN: buffer_store_dword v
48define void @no_extract_volatile_load_extract0(i32 addrspace(1)* %out, <4 x i32> addrspace(1)* %in) {
49entry:
50  %vec = load volatile <4 x i32>, <4 x i32> addrspace(1)* %in
51  %elt0 = extractelement <4 x i32> %vec, i32 0
52  store i32 %elt0, i32 addrspace(1)* %out
53  ret void
54}
55
56; GCN-LABEL: {{^}}no_extract_volatile_load_extract2:
57; GCN: buffer_load_dwordx4
58; GCN: buffer_store_dword v
59
60define void @no_extract_volatile_load_extract2(i32 addrspace(1)* %out, <4 x i32> addrspace(1)* %in) {
61entry:
62  %vec = load volatile <4 x i32>, <4 x i32> addrspace(1)* %in
63  %elt2 = extractelement <4 x i32> %vec, i32 2
64  store i32 %elt2, i32 addrspace(1)* %out
65  ret void
66}
67
68; GCN-LABEL: {{^}}no_extract_volatile_load_dynextract:
69; GCN: buffer_load_dwordx4
70; GCN: buffer_store_dword v
71define void @no_extract_volatile_load_dynextract(i32 addrspace(1)* %out, <4 x i32> addrspace(1)* %in, i32 %idx) {
72entry:
73  %vec = load volatile <4 x i32>, <4 x i32> addrspace(1)* %in
74  %eltN = extractelement <4 x i32> %vec, i32 %idx
75  store i32 %eltN, i32 addrspace(1)* %out
76  ret void
77}
78