]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CodeGen/R600/xor.ll
Vendor import of llvm RELEASE_360/rc1 tag r226102 (effectively, 3.6.0 RC1):
[FreeBSD/FreeBSD.git] / test / CodeGen / R600 / xor.ll
1 ; RUN: llc -march=amdgcn -mcpu=verde -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2 ; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
3
4
5 ; FUNC-LABEL: {{^}}xor_v2i32:
6 ; EG: XOR_INT {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
7 ; EG: XOR_INT {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
8
9 ; SI: v_xor_b32_e32 v{{[0-9]+, v[0-9]+, v[0-9]+}}
10 ; SI: v_xor_b32_e32 v{{[0-9]+, v[0-9]+, v[0-9]+}}
11
12 define void @xor_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> addrspace(1)* %in0, <2 x i32> addrspace(1)* %in1) {
13   %a = load <2 x i32> addrspace(1) * %in0
14   %b = load <2 x i32> addrspace(1) * %in1
15   %result = xor <2 x i32> %a, %b
16   store <2 x i32> %result, <2 x i32> addrspace(1)* %out
17   ret void
18 }
19
20 ; FUNC-LABEL: {{^}}xor_v4i32:
21 ; EG: XOR_INT {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
22 ; EG: XOR_INT {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
23 ; EG: XOR_INT {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
24 ; EG: XOR_INT {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
25
26 ; SI: v_xor_b32_e32 {{v[0-9]+, v[0-9]+, v[0-9]+}}
27 ; SI: v_xor_b32_e32 {{v[0-9]+, v[0-9]+, v[0-9]+}}
28 ; SI: v_xor_b32_e32 {{v[0-9]+, v[0-9]+, v[0-9]+}}
29 ; SI: v_xor_b32_e32 {{v[0-9]+, v[0-9]+, v[0-9]+}}
30
31 define void @xor_v4i32(<4 x i32> addrspace(1)* %out, <4 x i32> addrspace(1)* %in0, <4 x i32> addrspace(1)* %in1) {
32   %a = load <4 x i32> addrspace(1) * %in0
33   %b = load <4 x i32> addrspace(1) * %in1
34   %result = xor <4 x i32> %a, %b
35   store <4 x i32> %result, <4 x i32> addrspace(1)* %out
36   ret void
37 }
38
39 ; FUNC-LABEL: {{^}}xor_i1:
40 ; EG: XOR_INT {{\** *}}T{{[0-9]+\.[XYZW], PV\.[XYZW], PS}}
41
42 ; SI-DAG: v_cmp_ge_f32_e64 [[CMP0:s\[[0-9]+:[0-9]+\]]], {{v[0-9]+}}, 0
43 ; SI-DAG: v_cmp_ge_f32_e64 [[CMP1:s\[[0-9]+:[0-9]+\]]], {{v[0-9]+}}, 1.0
44 ; SI: s_xor_b64 [[XOR:s\[[0-9]+:[0-9]+\]]], [[CMP0]], [[CMP1]]
45 ; SI: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], {{v[0-9]+}}, {{v[0-9]+}}, [[XOR]]
46 ; SI: buffer_store_dword [[RESULT]]
47 ; SI: s_endpgm
48 define void @xor_i1(float addrspace(1)* %out, float addrspace(1)* %in0, float addrspace(1)* %in1) {
49   %a = load float addrspace(1) * %in0
50   %b = load float addrspace(1) * %in1
51   %acmp = fcmp oge float %a, 0.000000e+00
52   %bcmp = fcmp oge float %b, 1.000000e+00
53   %xor = xor i1 %acmp, %bcmp
54   %result = select i1 %xor, float %a, float %b
55   store float %result, float addrspace(1)* %out
56   ret void
57 }
58
59 ; FUNC-LABEL: {{^}}v_xor_i1:
60 ; SI: buffer_load_ubyte [[A:v[0-9]+]]
61 ; SI: buffer_load_ubyte [[B:v[0-9]+]]
62 ; SI: v_xor_b32_e32 [[XOR:v[0-9]+]], [[A]], [[B]]
63 ; SI: v_and_b32_e32 [[RESULT:v[0-9]+]], 1, [[XOR]]
64 ; SI: buffer_store_byte [[RESULT]]
65 define void @v_xor_i1(i1 addrspace(1)* %out, i1 addrspace(1)* %in0, i1 addrspace(1)* %in1) {
66   %a = load i1 addrspace(1)* %in0
67   %b = load i1 addrspace(1)* %in1
68   %xor = xor i1 %a, %b
69   store i1 %xor, i1 addrspace(1)* %out
70   ret void
71 }
72
73 ; FUNC-LABEL: {{^}}vector_xor_i32:
74 ; SI: v_xor_b32_e32
75 define void @vector_xor_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in0, i32 addrspace(1)* %in1) {
76   %a = load i32 addrspace(1)* %in0
77   %b = load i32 addrspace(1)* %in1
78   %result = xor i32 %a, %b
79   store i32 %result, i32 addrspace(1)* %out
80   ret void
81 }
82
83 ; FUNC-LABEL: {{^}}scalar_xor_i32:
84 ; SI: s_xor_b32
85 define void @scalar_xor_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) {
86   %result = xor i32 %a, %b
87   store i32 %result, i32 addrspace(1)* %out
88   ret void
89 }
90
91 ; FUNC-LABEL: {{^}}scalar_not_i32:
92 ; SI: s_not_b32
93 define void @scalar_not_i32(i32 addrspace(1)* %out, i32 %a) {
94   %result = xor i32 %a, -1
95   store i32 %result, i32 addrspace(1)* %out
96   ret void
97 }
98
99 ; FUNC-LABEL: {{^}}vector_not_i32:
100 ; SI: v_not_b32
101 define void @vector_not_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in0, i32 addrspace(1)* %in1) {
102   %a = load i32 addrspace(1)* %in0
103   %b = load i32 addrspace(1)* %in1
104   %result = xor i32 %a, -1
105   store i32 %result, i32 addrspace(1)* %out
106   ret void
107 }
108
109 ; FUNC-LABEL: {{^}}vector_xor_i64:
110 ; SI: v_xor_b32_e32
111 ; SI: v_xor_b32_e32
112 ; SI: s_endpgm
113 define void @vector_xor_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %in0, i64 addrspace(1)* %in1) {
114   %a = load i64 addrspace(1)* %in0
115   %b = load i64 addrspace(1)* %in1
116   %result = xor i64 %a, %b
117   store i64 %result, i64 addrspace(1)* %out
118   ret void
119 }
120
121 ; FUNC-LABEL: {{^}}scalar_xor_i64:
122 ; SI: s_xor_b64
123 ; SI: s_endpgm
124 define void @scalar_xor_i64(i64 addrspace(1)* %out, i64 %a, i64 %b) {
125   %result = xor i64 %a, %b
126   store i64 %result, i64 addrspace(1)* %out
127   ret void
128 }
129
130 ; FUNC-LABEL: {{^}}scalar_not_i64:
131 ; SI: s_not_b64
132 define void @scalar_not_i64(i64 addrspace(1)* %out, i64 %a) {
133   %result = xor i64 %a, -1
134   store i64 %result, i64 addrspace(1)* %out
135   ret void
136 }
137
138 ; FUNC-LABEL: {{^}}vector_not_i64:
139 ; SI: v_not_b32
140 ; SI: v_not_b32
141 define void @vector_not_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %in0, i64 addrspace(1)* %in1) {
142   %a = load i64 addrspace(1)* %in0
143   %b = load i64 addrspace(1)* %in1
144   %result = xor i64 %a, -1
145   store i64 %result, i64 addrspace(1)* %out
146   ret void
147 }
148
149 ; Test that we have a pattern to match xor inside a branch.
150 ; Note that in the future the backend may be smart enough to
151 ; use an SALU instruction for this.
152
153 ; FUNC-LABEL: {{^}}xor_cf:
154 ; SI: s_xor_b64
155 define void @xor_cf(i64 addrspace(1)* %out, i64 addrspace(1)* %in, i64 %a, i64 %b) {
156 entry:
157   %0 = icmp eq i64 %a, 0
158   br i1 %0, label %if, label %else
159
160 if:
161   %1 = xor i64 %a, %b
162   br label %endif
163
164 else:
165   %2 = load i64 addrspace(1)* %in
166   br label %endif
167
168 endif:
169   %3 = phi i64 [%1, %if], [%2, %else]
170   store i64 %3, i64 addrspace(1)* %out
171   ret void
172 }