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
5 ; ===================================================================================
7 ; ===================================================================================
9 define amdgpu_ps float @xor3(i32 %a, i32 %b, i32 %c) {
12 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
13 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v2
14 ; GFX9-NEXT: ; return to shader part epilog
18 ; GFX10-NEXT: v_xor3_b32 v0, v0, v1, v2
19 ; GFX10-NEXT: ; implicit-def: $vcc_hi
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: v_xor_b32_e32 v0, s2, v0
31 ; GFX9-NEXT: v_xor_b32_e32 v0, s3, v0
32 ; GFX9-NEXT: ; return to shader part epilog
34 ; GFX10-LABEL: xor3_vgpr_b:
36 ; GFX10-NEXT: v_xor3_b32 v0, s2, v0, s3
37 ; GFX10-NEXT: ; implicit-def: $vcc_hi
38 ; GFX10-NEXT: ; return to shader part epilog
40 %result = xor i32 %x, %c
41 %bc = bitcast i32 %result to float
45 define amdgpu_ps float @xor3_vgpr_all2(i32 %a, i32 %b, i32 %c) {
46 ; GFX9-LABEL: xor3_vgpr_all2:
48 ; GFX9-NEXT: v_xor_b32_e32 v1, v1, v2
49 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
50 ; GFX9-NEXT: ; return to shader part epilog
52 ; GFX10-LABEL: xor3_vgpr_all2:
54 ; GFX10-NEXT: v_xor3_b32 v0, v1, v2, v0
55 ; GFX10-NEXT: ; implicit-def: $vcc_hi
56 ; GFX10-NEXT: ; return to shader part epilog
58 %result = xor i32 %a, %x
59 %bc = bitcast i32 %result to float
63 define amdgpu_ps float @xor3_vgpr_bc(i32 inreg %a, i32 %b, i32 %c) {
64 ; GFX9-LABEL: xor3_vgpr_bc:
66 ; GFX9-NEXT: v_xor_b32_e32 v0, s2, v0
67 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
68 ; GFX9-NEXT: ; return to shader part epilog
70 ; GFX10-LABEL: xor3_vgpr_bc:
72 ; GFX10-NEXT: v_xor3_b32 v0, s2, v0, v1
73 ; GFX10-NEXT: ; implicit-def: $vcc_hi
74 ; GFX10-NEXT: ; return to shader part epilog
76 %result = xor i32 %x, %c
77 %bc = bitcast i32 %result to float
81 define amdgpu_ps float @xor3_vgpr_const(i32 %a, i32 %b) {
82 ; GFX9-LABEL: xor3_vgpr_const:
84 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
85 ; GFX9-NEXT: v_xor_b32_e32 v0, 16, v0
86 ; GFX9-NEXT: ; return to shader part epilog
88 ; GFX10-LABEL: xor3_vgpr_const:
90 ; GFX10-NEXT: v_xor3_b32 v0, v0, v1, 16
91 ; GFX10-NEXT: ; implicit-def: $vcc_hi
92 ; GFX10-NEXT: ; return to shader part epilog
94 %result = xor i32 %x, 16
95 %bc = bitcast i32 %result to float
99 define amdgpu_ps <2 x float> @xor3_multiuse_outer(i32 %a, i32 %b, i32 %c, i32 %x) {
100 ; GFX9-LABEL: xor3_multiuse_outer:
102 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
103 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v2
104 ; GFX9-NEXT: v_mul_lo_u32 v1, v0, v3
105 ; GFX9-NEXT: ; return to shader part epilog
107 ; GFX10-LABEL: xor3_multiuse_outer:
109 ; GFX10-NEXT: v_xor3_b32 v0, v0, v1, v2
110 ; GFX10-NEXT: ; implicit-def: $vcc_hi
111 ; GFX10-NEXT: v_mul_lo_u32 v1, v0, v3
112 ; GFX10-NEXT: ; return to shader part epilog
113 %inner = xor i32 %a, %b
114 %outer = xor i32 %inner, %c
115 %x1 = mul i32 %outer, %x
116 %r1 = insertelement <2 x i32> undef, i32 %outer, i32 0
117 %r0 = insertelement <2 x i32> %r1, i32 %x1, i32 1
118 %bc = bitcast <2 x i32> %r0 to <2 x float>
122 define amdgpu_ps <2 x float> @xor3_multiuse_inner(i32 %a, i32 %b, i32 %c) {
123 ; GFX9-LABEL: xor3_multiuse_inner:
125 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
126 ; GFX9-NEXT: v_xor_b32_e32 v1, v0, v2
127 ; GFX9-NEXT: ; return to shader part epilog
129 ; GFX10-LABEL: xor3_multiuse_inner:
131 ; GFX10-NEXT: v_xor_b32_e32 v0, v0, v1
132 ; GFX10-NEXT: ; implicit-def: $vcc_hi
133 ; GFX10-NEXT: v_xor_b32_e32 v1, v0, v2
134 ; GFX10-NEXT: ; return to shader part epilog
135 %inner = xor i32 %a, %b
136 %outer = xor i32 %inner, %c
137 %r1 = insertelement <2 x i32> undef, i32 %inner, i32 0
138 %r0 = insertelement <2 x i32> %r1, i32 %outer, i32 1
139 %bc = bitcast <2 x i32> %r0 to <2 x float>
143 ; A case where uniform values end up in VGPRs -- we could use v_xor3_b32 here,
145 define amdgpu_ps float @xor3_uniform_vgpr(float inreg %a, float inreg %b, float inreg %c) {
146 ; GFX9-LABEL: xor3_uniform_vgpr:
148 ; GFX9-NEXT: v_mov_b32_e32 v2, 0x40400000
149 ; GFX9-NEXT: v_add_f32_e64 v0, s2, 1.0
150 ; GFX9-NEXT: v_add_f32_e64 v1, s3, 2.0
151 ; GFX9-NEXT: v_add_f32_e32 v2, s4, v2
152 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
153 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v2
154 ; GFX9-NEXT: ; return to shader part epilog
156 ; GFX10-LABEL: xor3_uniform_vgpr:
158 ; GFX10-NEXT: v_add_f32_e64 v1, s3, 2.0
159 ; GFX10-NEXT: v_add_f32_e64 v2, s2, 1.0
160 ; GFX10-NEXT: v_add_f32_e64 v0, 0x40400000, s4
161 ; GFX10-NEXT: ; implicit-def: $vcc_hi
162 ; GFX10-NEXT: v_xor_b32_e32 v1, v2, v1
163 ; GFX10-NEXT: v_xor_b32_e32 v0, v1, v0
164 ; GFX10-NEXT: ; return to shader part epilog
165 %a1 = fadd float %a, 1.0
166 %b2 = fadd float %b, 2.0
167 %c3 = fadd float %c, 3.0
168 %bc.a = bitcast float %a1 to i32
169 %bc.b = bitcast float %b2 to i32
170 %bc.c = bitcast float %c3 to i32
171 %x = xor i32 %bc.a, %bc.b
172 %result = xor i32 %x, %bc.c
173 %bc = bitcast i32 %result to float