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: ; return to shader part epilog
21 %result = xor i32 %x, %c
22 %bc = bitcast i32 %result to float
26 define amdgpu_ps float @xor3_vgpr_b(i32 inreg %a, i32 %b, i32 inreg %c) {
27 ; GFX9-LABEL: xor3_vgpr_b:
29 ; GFX9-NEXT: v_xor_b32_e32 v0, s2, v0
30 ; GFX9-NEXT: v_xor_b32_e32 v0, s3, v0
31 ; GFX9-NEXT: ; return to shader part epilog
33 ; GFX10-LABEL: xor3_vgpr_b:
35 ; GFX10-NEXT: v_xor3_b32 v0, s2, v0, s3
36 ; GFX10-NEXT: ; return to shader part epilog
38 %result = xor i32 %x, %c
39 %bc = bitcast i32 %result to float
43 define amdgpu_ps float @xor3_vgpr_all2(i32 %a, i32 %b, i32 %c) {
44 ; GFX9-LABEL: xor3_vgpr_all2:
46 ; GFX9-NEXT: v_xor_b32_e32 v1, v1, v2
47 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
48 ; GFX9-NEXT: ; return to shader part epilog
50 ; GFX10-LABEL: xor3_vgpr_all2:
52 ; GFX10-NEXT: v_xor3_b32 v0, v1, v2, v0
53 ; GFX10-NEXT: ; return to shader part epilog
55 %result = xor i32 %a, %x
56 %bc = bitcast i32 %result to float
60 define amdgpu_ps float @xor3_vgpr_bc(i32 inreg %a, i32 %b, i32 %c) {
61 ; GFX9-LABEL: xor3_vgpr_bc:
63 ; GFX9-NEXT: v_xor_b32_e32 v0, s2, v0
64 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
65 ; GFX9-NEXT: ; return to shader part epilog
67 ; GFX10-LABEL: xor3_vgpr_bc:
69 ; GFX10-NEXT: v_xor3_b32 v0, s2, v0, v1
70 ; GFX10-NEXT: ; return to shader part epilog
72 %result = xor i32 %x, %c
73 %bc = bitcast i32 %result to float
77 define amdgpu_ps float @xor3_vgpr_const(i32 %a, i32 %b) {
78 ; GFX9-LABEL: xor3_vgpr_const:
80 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
81 ; GFX9-NEXT: v_xor_b32_e32 v0, 16, v0
82 ; GFX9-NEXT: ; return to shader part epilog
84 ; GFX10-LABEL: xor3_vgpr_const:
86 ; GFX10-NEXT: v_xor3_b32 v0, v0, v1, 16
87 ; GFX10-NEXT: ; return to shader part epilog
89 %result = xor i32 %x, 16
90 %bc = bitcast i32 %result to float
94 define amdgpu_ps <2 x float> @xor3_multiuse_outer(i32 %a, i32 %b, i32 %c, i32 %x) {
95 ; GFX9-LABEL: xor3_multiuse_outer:
97 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
98 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v2
99 ; GFX9-NEXT: v_mul_lo_u32 v1, v0, v3
100 ; GFX9-NEXT: ; return to shader part epilog
102 ; GFX10-LABEL: xor3_multiuse_outer:
104 ; GFX10-NEXT: v_xor3_b32 v0, v0, v1, v2
105 ; GFX10-NEXT: v_mul_lo_u32 v1, v0, v3
106 ; GFX10-NEXT: ; return to shader part epilog
107 %inner = xor i32 %a, %b
108 %outer = xor i32 %inner, %c
109 %x1 = mul i32 %outer, %x
110 %r1 = insertelement <2 x i32> undef, i32 %outer, i32 0
111 %r0 = insertelement <2 x i32> %r1, i32 %x1, i32 1
112 %bc = bitcast <2 x i32> %r0 to <2 x float>
116 define amdgpu_ps <2 x float> @xor3_multiuse_inner(i32 %a, i32 %b, i32 %c) {
117 ; GFX9-LABEL: xor3_multiuse_inner:
119 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
120 ; GFX9-NEXT: v_xor_b32_e32 v1, v0, v2
121 ; GFX9-NEXT: ; return to shader part epilog
123 ; GFX10-LABEL: xor3_multiuse_inner:
125 ; GFX10-NEXT: v_xor_b32_e32 v0, v0, v1
126 ; GFX10-NEXT: v_xor_b32_e32 v1, v0, v2
127 ; GFX10-NEXT: ; return to shader part epilog
128 %inner = xor i32 %a, %b
129 %outer = xor i32 %inner, %c
130 %r1 = insertelement <2 x i32> undef, i32 %inner, i32 0
131 %r0 = insertelement <2 x i32> %r1, i32 %outer, i32 1
132 %bc = bitcast <2 x i32> %r0 to <2 x float>
136 ; A case where uniform values end up in VGPRs -- we could use v_xor3_b32 here,
138 define amdgpu_ps float @xor3_uniform_vgpr(float inreg %a, float inreg %b, float inreg %c) {
139 ; GFX9-LABEL: xor3_uniform_vgpr:
141 ; GFX9-NEXT: v_mov_b32_e32 v2, 0x40400000
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_add_f32_e32 v2, s4, v2
145 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
146 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v2
147 ; GFX9-NEXT: ; return to shader part epilog
149 ; GFX10-LABEL: xor3_uniform_vgpr:
151 ; GFX10-NEXT: v_add_f32_e64 v0, s2, 1.0
152 ; GFX10-NEXT: v_add_f32_e64 v1, s3, 2.0
153 ; GFX10-NEXT: v_add_f32_e64 v2, 0x40400000, s4
154 ; GFX10-NEXT: v_xor_b32_e32 v0, v0, v1
155 ; GFX10-NEXT: v_xor_b32_e32 v0, v0, v2
156 ; GFX10-NEXT: ; return to shader part epilog
157 %a1 = fadd float %a, 1.0
158 %b2 = fadd float %b, 2.0
159 %c3 = fadd float %c, 3.0
160 %bc.a = bitcast float %a1 to i32
161 %bc.b = bitcast float %b2 to i32
162 %bc.c = bitcast float %c3 to i32
163 %x = xor i32 %bc.a, %bc.b
164 %result = xor i32 %x, %bc.c
165 %bc = bitcast i32 %result to float