1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=amdgcn-amd-mesa3d -mcpu=gfx900 -verify-machineinstrs | FileCheck -check-prefix=GFX9 %s
3 ; RUN: llc < %s -mtriple=amdgcn-amd-mesa3d -mcpu=gfx1010 -verify-machineinstrs | FileCheck -check-prefix=GFX10 %s
4 ; RUN: llc < %s -mtriple=amdgcn-amd-mesa3d -mcpu=gfx1100 -amdgpu-enable-delay-alu=0 -verify-machineinstrs | FileCheck -check-prefix=GFX10 %s
6 ; ===================================================================================
8 ; ===================================================================================
10 define amdgpu_ps float @xor3(i32 %a, i32 %b, i32 %c) {
13 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
14 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v2
15 ; GFX9-NEXT: ; return to shader part epilog
19 ; GFX10-NEXT: v_xor3_b32 v0, v0, v1, v2
20 ; GFX10-NEXT: ; return to shader part epilog
22 %result = xor i32 %x, %c
23 %bc = bitcast i32 %result to float
27 define amdgpu_ps float @xor3_vgpr_b(i32 inreg %a, i32 %b, i32 inreg %c) {
28 ; GFX9-LABEL: xor3_vgpr_b:
30 ; GFX9-NEXT: s_xor_b32 s0, s3, s2
31 ; GFX9-NEXT: v_xor_b32_e32 v0, s0, v0
32 ; GFX9-NEXT: ; return to shader part epilog
34 ; GFX10-LABEL: xor3_vgpr_b:
36 ; GFX10-NEXT: v_xor3_b32 v0, s3, s2, v0
37 ; GFX10-NEXT: ; return to shader part epilog
39 %result = xor i32 %x, %c
40 %bc = bitcast i32 %result to float
44 define amdgpu_ps float @xor3_vgpr_all2(i32 %a, i32 %b, i32 %c) {
45 ; GFX9-LABEL: xor3_vgpr_all2:
47 ; GFX9-NEXT: v_xor_b32_e32 v1, v1, v2
48 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
49 ; GFX9-NEXT: ; return to shader part epilog
51 ; GFX10-LABEL: xor3_vgpr_all2:
53 ; GFX10-NEXT: v_xor3_b32 v0, v1, v2, v0
54 ; GFX10-NEXT: ; return to shader part epilog
56 %result = xor i32 %a, %x
57 %bc = bitcast i32 %result to float
61 define amdgpu_ps float @xor3_vgpr_bc(i32 inreg %a, i32 %b, i32 %c) {
62 ; GFX9-LABEL: xor3_vgpr_bc:
64 ; GFX9-NEXT: v_xor_b32_e32 v0, s2, v0
65 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
66 ; GFX9-NEXT: ; return to shader part epilog
68 ; GFX10-LABEL: xor3_vgpr_bc:
70 ; GFX10-NEXT: v_xor3_b32 v0, s2, v0, v1
71 ; GFX10-NEXT: ; return to shader part epilog
73 %result = xor i32 %x, %c
74 %bc = bitcast i32 %result to float
78 define amdgpu_ps float @xor3_vgpr_const(i32 %a, i32 %b) {
79 ; GFX9-LABEL: xor3_vgpr_const:
81 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
82 ; GFX9-NEXT: v_xor_b32_e32 v0, 16, v0
83 ; GFX9-NEXT: ; return to shader part epilog
85 ; GFX10-LABEL: xor3_vgpr_const:
87 ; GFX10-NEXT: v_xor3_b32 v0, v0, v1, 16
88 ; GFX10-NEXT: ; return to shader part epilog
90 %result = xor i32 %x, 16
91 %bc = bitcast i32 %result to float
95 define amdgpu_ps <2 x float> @xor3_multiuse_outer(i32 %a, i32 %b, i32 %c, i32 %x) {
96 ; GFX9-LABEL: xor3_multiuse_outer:
98 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
99 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v2
100 ; GFX9-NEXT: v_mul_lo_u32 v1, v0, v3
101 ; GFX9-NEXT: ; return to shader part epilog
103 ; GFX10-LABEL: xor3_multiuse_outer:
105 ; GFX10-NEXT: v_xor3_b32 v0, v0, v1, v2
106 ; GFX10-NEXT: v_mul_lo_u32 v1, v0, v3
107 ; GFX10-NEXT: ; return to shader part epilog
108 %inner = xor i32 %a, %b
109 %outer = xor i32 %inner, %c
110 %x1 = mul i32 %outer, %x
111 %r1 = insertelement <2 x i32> undef, i32 %outer, i32 0
112 %r0 = insertelement <2 x i32> %r1, i32 %x1, i32 1
113 %bc = bitcast <2 x i32> %r0 to <2 x float>
117 define amdgpu_ps <2 x float> @xor3_multiuse_inner(i32 %a, i32 %b, i32 %c) {
118 ; GFX9-LABEL: xor3_multiuse_inner:
120 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
121 ; GFX9-NEXT: v_xor_b32_e32 v1, v0, v2
122 ; GFX9-NEXT: ; return to shader part epilog
124 ; GFX10-LABEL: xor3_multiuse_inner:
126 ; GFX10-NEXT: v_xor_b32_e32 v0, v0, v1
127 ; GFX10-NEXT: v_xor_b32_e32 v1, v0, v2
128 ; GFX10-NEXT: ; return to shader part epilog
129 %inner = xor i32 %a, %b
130 %outer = xor i32 %inner, %c
131 %r1 = insertelement <2 x i32> undef, i32 %inner, i32 0
132 %r0 = insertelement <2 x i32> %r1, i32 %outer, i32 1
133 %bc = bitcast <2 x i32> %r0 to <2 x float>
137 ; A case where uniform values end up in VGPRs -- we could use v_xor3_b32 here,
139 define amdgpu_ps float @xor3_uniform_vgpr(float inreg %a, float inreg %b, float inreg %c) {
140 ; GFX9-LABEL: xor3_uniform_vgpr:
142 ; GFX9-NEXT: v_add_f32_e64 v0, s2, 1.0
143 ; GFX9-NEXT: v_add_f32_e64 v1, s3, 2.0
144 ; GFX9-NEXT: v_mov_b32_e32 v2, 0x40400000
145 ; GFX9-NEXT: v_add_f32_e32 v2, s4, v2
146 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
147 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v2
148 ; GFX9-NEXT: ; return to shader part epilog
150 ; GFX10-LABEL: xor3_uniform_vgpr:
152 ; GFX10-NEXT: v_add_f32_e64 v0, s2, 1.0
153 ; GFX10-NEXT: v_add_f32_e64 v1, s3, 2.0
154 ; GFX10-NEXT: v_add_f32_e64 v2, 0x40400000, s4
155 ; GFX10-NEXT: v_xor_b32_e32 v0, v0, v1
156 ; GFX10-NEXT: v_xor_b32_e32 v0, v0, v2
157 ; GFX10-NEXT: ; return to shader part epilog
158 %a1 = fadd float %a, 1.0
159 %b2 = fadd float %b, 2.0
160 %c3 = fadd float %c, 3.0
161 %bc.a = bitcast float %a1 to i32
162 %bc.b = bitcast float %b2 to i32
163 %bc.c = bitcast float %c3 to i32
164 %x = xor i32 %bc.a, %bc.b
165 %result = xor i32 %x, %bc.c
166 %bc = bitcast i32 %result to float