• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
3
4; FUNC-LABEL {{^}}sextload_i1_to_i32_trunc_cmp_eq_0:
5; SI: buffer_load_ubyte [[LOAD:v[0-9]+]]
6; SI: v_and_b32_e32 [[TMP:v[0-9]+]], 1, [[LOAD]]
7; SI: v_cmp_eq_i32_e32 vcc, 0, [[TMP]]{{$}}
8; SI: v_cndmask_b32_e64
9; SI: buffer_store_byte
10define void @sextload_i1_to_i32_trunc_cmp_eq_0(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
11  %load = load i1, i1 addrspace(1)* %in
12  %ext = sext i1 %load to i32
13  %cmp = icmp eq i32 %ext, 0
14  store i1 %cmp, i1 addrspace(1)* %out
15  ret void
16}
17
18; FIXME: The negate should be inverting the compare.
19; FUNC-LABEL: {{^}}zextload_i1_to_i32_trunc_cmp_eq_0:
20; SI: buffer_load_ubyte [[LOAD:v[0-9]+]]
21; SI: v_and_b32_e32 [[TMP:v[0-9]+]], 1, [[LOAD]]
22; SI: v_cmp_eq_i32_e32 vcc, 1, [[TMP]]{{$}}
23; SI-NEXT: s_xor_b64 [[NEG:s\[[0-9]+:[0-9]+\]]], vcc, -1
24; SI-NEXT: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0, 1, [[NEG]]
25; SI: buffer_store_byte [[RESULT]]
26define void @zextload_i1_to_i32_trunc_cmp_eq_0(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
27  %load = load i1, i1 addrspace(1)* %in
28  %ext = zext i1 %load to i32
29  %cmp = icmp eq i32 %ext, 0
30  store i1 %cmp, i1 addrspace(1)* %out
31  ret void
32}
33
34; FUNC-LABEL: {{^}}sextload_i1_to_i32_trunc_cmp_eq_1:
35; SI: v_mov_b32_e32 [[RESULT:v[0-9]+]], 0{{$}}
36; SI: buffer_store_byte [[RESULT]]
37define void @sextload_i1_to_i32_trunc_cmp_eq_1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
38  %load = load i1, i1 addrspace(1)* %in
39  %ext = sext i1 %load to i32
40  %cmp = icmp eq i32 %ext, 1
41  store i1 %cmp, i1 addrspace(1)* %out
42  ret void
43}
44
45; FUNC-LABEL: {{^}}zextload_i1_to_i32_trunc_cmp_eq_1:
46; SI: buffer_load_ubyte [[LOAD:v[0-9]+]]
47; SI: v_and_b32_e32 [[RESULT:v[0-9]+]], 1, [[LOAD]]
48; SI: buffer_store_byte [[RESULT]]
49define void @zextload_i1_to_i32_trunc_cmp_eq_1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
50  %load = load i1, i1 addrspace(1)* %in
51  %ext = zext i1 %load to i32
52  %cmp = icmp eq i32 %ext, 1
53  store i1 %cmp, i1 addrspace(1)* %out
54  ret void
55}
56
57; FUNC-LABEL: {{^}}sextload_i1_to_i32_trunc_cmp_eq_neg1:
58; SI: buffer_load_ubyte [[LOAD:v[0-9]+]]
59; SI: v_and_b32_e32 [[RESULT:v[0-9]+]], 1, [[LOAD]]
60; SI: buffer_store_byte [[RESULT]]
61define void @sextload_i1_to_i32_trunc_cmp_eq_neg1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
62  %load = load i1, i1 addrspace(1)* %in
63  %ext = sext i1 %load to i32
64  %cmp = icmp eq i32 %ext, -1
65  store i1 %cmp, i1 addrspace(1)* %out
66  ret void
67}
68
69; FUNC-LABEL: {{^}}zextload_i1_to_i32_trunc_cmp_eq_neg1:
70; SI: v_mov_b32_e32 [[RESULT:v[0-9]+]], 0{{$}}
71; SI: buffer_store_byte [[RESULT]]
72define void @zextload_i1_to_i32_trunc_cmp_eq_neg1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
73  %load = load i1, i1 addrspace(1)* %in
74  %ext = zext i1 %load to i32
75  %cmp = icmp eq i32 %ext, -1
76  store i1 %cmp, i1 addrspace(1)* %out
77  ret void
78}
79
80
81; FUNC-LABEL {{^}}sextload_i1_to_i32_trunc_cmp_ne_0:
82; SI: buffer_load_ubyte [[LOAD:v[0-9]+]]
83; SI: v_and_b32_e32 [[TMP:v[0-9]+]], 1, [[LOAD]]
84; SI: buffer_store_byte [[RESULT]]
85define void @sextload_i1_to_i32_trunc_cmp_ne_0(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
86  %load = load i1, i1 addrspace(1)* %in
87  %ext = sext i1 %load to i32
88  %cmp = icmp ne i32 %ext, 0
89  store i1 %cmp, i1 addrspace(1)* %out
90  ret void
91}
92
93; FUNC-LABEL: {{^}}zextload_i1_to_i32_trunc_cmp_ne_0:
94; SI: buffer_load_ubyte [[LOAD:v[0-9]+]]
95; SI: v_and_b32_e32 [[TMP:v[0-9]+]], 1, [[LOAD]]
96; SI: buffer_store_byte [[RESULT]]
97define void @zextload_i1_to_i32_trunc_cmp_ne_0(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
98  %load = load i1, i1 addrspace(1)* %in
99  %ext = zext i1 %load to i32
100  %cmp = icmp ne i32 %ext, 0
101  store i1 %cmp, i1 addrspace(1)* %out
102  ret void
103}
104
105; FUNC-LABEL: {{^}}sextload_i1_to_i32_trunc_cmp_ne_1:
106; SI: v_mov_b32_e32 [[RESULT:v[0-9]+]], 1{{$}}
107; SI: buffer_store_byte [[RESULT]]
108define void @sextload_i1_to_i32_trunc_cmp_ne_1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
109  %load = load i1, i1 addrspace(1)* %in
110  %ext = sext i1 %load to i32
111  %cmp = icmp ne i32 %ext, 1
112  store i1 %cmp, i1 addrspace(1)* %out
113  ret void
114}
115
116; FUNC-LABEL: {{^}}zextload_i1_to_i32_trunc_cmp_ne_1:
117; SI: buffer_load_ubyte [[LOAD:v[0-9]+]]
118; SI: v_and_b32_e32 [[TMP:v[0-9]+]], 1, [[LOAD]]
119; SI: v_cmp_eq_i32_e32 vcc, 1, [[TMP]]{{$}}
120; SI-NEXT: s_xor_b64 [[NEG:s\[[0-9]+:[0-9]+\]]], vcc, -1
121; SI-NEXT: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0, 1, [[NEG]]
122; SI: buffer_store_byte [[RESULT]]
123define void @zextload_i1_to_i32_trunc_cmp_ne_1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
124  %load = load i1, i1 addrspace(1)* %in
125  %ext = zext i1 %load to i32
126  %cmp = icmp ne i32 %ext, 1
127  store i1 %cmp, i1 addrspace(1)* %out
128  ret void
129}
130
131; FIXME: This should be one compare.
132; FUNC-LABEL: {{^}}sextload_i1_to_i32_trunc_cmp_ne_neg1:
133; XSI: buffer_load_ubyte [[LOAD:v[0-9]+]]
134; XSI: v_and_b32_e32 [[TMP:v[0-9]+]], 1, [[LOAD]]
135; XSI: v_cmp_eq_i32_e64 [[CMP0:s\[[0-9]+:[0-9]+\]]], [[TMP]], 0{{$}}
136; XSI-NEXT: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0, 1, [[CMP0]]
137; XSI-NEXT: buffer_store_byte [[RESULT]]
138define void @sextload_i1_to_i32_trunc_cmp_ne_neg1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
139  %load = load i1, i1 addrspace(1)* %in
140  %ext = sext i1 %load to i32
141  %cmp = icmp ne i32 %ext, -1
142  store i1 %cmp, i1 addrspace(1)* %out
143  ret void
144}
145
146; FUNC-LABEL: {{^}}zextload_i1_to_i32_trunc_cmp_ne_neg1:
147; SI: v_mov_b32_e32 [[RESULT:v[0-9]+]], 1{{$}}
148; SI: buffer_store_byte [[RESULT]]
149define void @zextload_i1_to_i32_trunc_cmp_ne_neg1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind {
150  %load = load i1, i1 addrspace(1)* %in
151  %ext = zext i1 %load to i32
152  %cmp = icmp ne i32 %ext, -1
153  store i1 %cmp, i1 addrspace(1)* %out
154  ret void
155}
156
157; FUNC-LABEL: {{^}}masked_load_i1_to_i32_trunc_cmp_ne_neg1:
158; SI: buffer_load_sbyte [[LOAD:v[0-9]+]]
159; SI: v_cmp_ne_i32_e32 vcc, -1, [[LOAD]]{{$}}
160; SI-NEXT: v_cndmask_b32_e64
161; SI: buffer_store_byte
162define void @masked_load_i1_to_i32_trunc_cmp_ne_neg1(i1 addrspace(1)* %out, i8 addrspace(1)* %in) nounwind {
163  %load = load i8, i8 addrspace(1)* %in
164  %masked = and i8 %load, 255
165  %ext = sext i8 %masked to i32
166  %cmp = icmp ne i32 %ext, -1
167  store i1 %cmp, i1 addrspace(1)* %out
168  ret void
169}
170