1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
|
; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
; Test fcmp pred (fneg x), c -> fcmp (swapped pred) x, -c combine.
; GCN-LABEL: {{^}}multi_use_fneg_src:
; GCN: buffer_load_dword [[A:v[0-9]+]]
; GCN: buffer_load_dword [[B:v[0-9]+]]
; GCN: buffer_load_dword [[C:v[0-9]+]]
; GCN: v_mul_f32_e32 [[MUL:v[0-9]+]], [[A]], [[B]]
; GCN: v_cmp_eq_f32_e32 vcc, -4.0, [[MUL]]
; GCN: buffer_store_dword [[MUL]]
define amdgpu_kernel void @multi_use_fneg_src() #0 {
%a = load volatile float, ptr addrspace(1) undef
%b = load volatile float, ptr addrspace(1) undef
%x = load volatile i32, ptr addrspace(1) undef
%y = load volatile i32, ptr addrspace(1) undef
%mul = fmul float %a, %b
%neg.mul = fsub float -0.0, %mul
%cmp = fcmp oeq float %neg.mul, 4.0
%select = select i1 %cmp, i32 %x, i32 %y
store volatile i32 %select, ptr addrspace(1) undef
store volatile float %mul, ptr addrspace(1) undef
ret void
}
; GCN-LABEL: {{^}}multi_foldable_use_fneg_src:
; GCN: buffer_load_dword [[A:v[0-9]+]]
; GCN: buffer_load_dword [[B:v[0-9]+]]
; GCN: buffer_load_dword [[C:v[0-9]+]]
; GCN: v_mul_f32_e32 [[MUL:v[0-9]+]], [[A]], [[B]]
; GCN: v_cmp_eq_f32_e32 vcc, -4.0, [[A]]
; GCN: v_mul_f32_e64 [[USE1:v[0-9]+]], [[MUL]], -[[MUL]]
define amdgpu_kernel void @multi_foldable_use_fneg_src() #0 {
%a = load volatile float, ptr addrspace(1) undef
%b = load volatile float, ptr addrspace(1) undef
%x = load volatile i32, ptr addrspace(1) undef
%y = load volatile i32, ptr addrspace(1) undef
%mul = fmul float %a, %b
%neg.mul = fsub float -0.0, %mul
%use1 = fmul float %mul, %neg.mul
%cmp = fcmp oeq float %neg.mul, 4.0
%select = select i1 %cmp, i32 %x, i32 %y
store volatile i32 %select, ptr addrspace(1) undef
store volatile float %use1, ptr addrspace(1) undef
ret void
}
; GCN-LABEL: {{^}}multi_use_fneg:
; GCN: buffer_load_dword [[A:v[0-9]+]]
; GCN: buffer_load_dword [[B:v[0-9]+]]
; GCN: buffer_load_dword [[C:v[0-9]+]]
; GCN: v_mul_f32_e64 [[MUL:v[0-9]+]], [[A]], -[[B]]
; GCN-NEXT: v_cmp_eq_f32_e32 vcc, 4.0, [[MUL]]
; GCN-NOT: xor
; GCN: buffer_store_dword [[MUL]]
define amdgpu_kernel void @multi_use_fneg() #0 {
%a = load volatile float, ptr addrspace(1) undef
%b = load volatile float, ptr addrspace(1) undef
%x = load volatile i32, ptr addrspace(1) undef
%y = load volatile i32, ptr addrspace(1) undef
%mul = fmul float %a, %b
%neg.mul = fsub float -0.0, %mul
%cmp = fcmp oeq float %neg.mul, 4.0
%select = select i1 %cmp, i32 %x, i32 %y
store volatile i32 %select, ptr addrspace(1) undef
store volatile float %neg.mul, ptr addrspace(1) undef
ret void
}
; GCN-LABEL: {{^}}multi_foldable_use_fneg:
; GCN: buffer_load_dword [[A:v[0-9]+]]
; GCN: buffer_load_dword [[B:v[0-9]+]]
; GCN: v_mul_f32_e32 [[MUL0:v[0-9]+]], [[A]], [[B]]
; GCN: v_cmp_eq_f32_e32 vcc, -4.0, [[MUL0]]
; GCN: v_mul_f32_e64 [[MUL1:v[0-9]+]], -[[MUL0]], [[MUL0]]
; GCN: buffer_store_dword [[MUL1]]
define amdgpu_kernel void @multi_foldable_use_fneg() #0 {
%a = load volatile float, ptr addrspace(1) undef
%b = load volatile float, ptr addrspace(1) undef
%x = load volatile i32, ptr addrspace(1) undef
%y = load volatile i32, ptr addrspace(1) undef
%z = load volatile i32, ptr addrspace(1) undef
%mul = fmul float %a, %b
%neg.mul = fsub float -0.0, %mul
%cmp = fcmp oeq float %neg.mul, 4.0
%select = select i1 %cmp, i32 %x, i32 %y
%use1 = fmul float %neg.mul, %mul
store volatile i32 %select, ptr addrspace(1) undef
store volatile float %use1, ptr addrspace(1) undef
ret void
}
; GCN-LABEL: {{^}}test_setcc_fneg_oeq_posk_f32:
; GCN: v_cmp_eq_f32_e32 vcc, -4.0, v{{[0-9]+}}
define amdgpu_kernel void @test_setcc_fneg_oeq_posk_f32() #0 {
%a = load volatile float, ptr addrspace(1) undef
%x = load volatile i32, ptr addrspace(1) undef
%y = load volatile i32, ptr addrspace(1) undef
%neg.a = fsub float -0.0, %a
%cmp = fcmp oeq float %neg.a, 4.0
%select = select i1 %cmp, i32 %x, i32 %y
store volatile i32 %select, ptr addrspace(1) undef
ret void
}
; GCN-LABEL: {{^}}test_setcc_fneg_ogt_posk_f32:
; GCN: v_cmp_gt_f32_e32 vcc, -4.0, v{{[0-9]+}}
define amdgpu_kernel void @test_setcc_fneg_ogt_posk_f32() #0 {
%a = load volatile float, ptr addrspace(1) undef
%x = load volatile i32, ptr addrspace(1) undef
%y = load volatile i32, ptr addrspace(1) undef
%neg.a = fsub float -0.0, %a
%cmp = fcmp ogt float %neg.a, 4.0
%select = select i1 %cmp, i32 %x, i32 %y
store volatile i32 %select, ptr addrspace(1) undef
ret void
}
; GCN-LABEL: {{^}}test_setcc_fneg_oge_posk_f32:
; GCN: v_cmp_ge_f32_e32 vcc, -4.0, v{{[0-9]+}}
define amdgpu_kernel void @test_setcc_fneg_oge_posk_f32() #0 {
%a = load volatile float, ptr addrspace(1) undef
%x = load volatile i32, ptr addrspace(1) undef
%y = load volatile i32, ptr addrspace(1) undef
%neg.a = fsub float -0.0, %a
%cmp = fcmp oge float %neg.a, 4.0
%select = select i1 %cmp, i32 %x, i32 %y
store volatile i32 %select, ptr addrspace(1) undef
ret void
}
; GCN-LABEL: {{^}}test_setcc_fneg_olt_posk_f32:
; GCN: v_cmp_lt_f32_e32 vcc, -4.0, v{{[0-9]+}}
define amdgpu_kernel void @test_setcc_fneg_olt_posk_f32() #0 {
%a = load volatile float, ptr addrspace(1) undef
%x = load volatile i32, ptr addrspace(1) undef
%y = load volatile i32, ptr addrspace(1) undef
%neg.a = fsub float -0.0, %a
%cmp = fcmp olt float %neg.a, 4.0
%select = select i1 %cmp, i32 %x, i32 %y
store volatile i32 %select, ptr addrspace(1) undef
ret void
}
; GCN-LABEL: {{^}}test_setcc_fneg_ole_posk_f32:
; GCN: v_cmp_le_f32_e32 vcc, -4.0, v{{[0-9]+}}
define amdgpu_kernel void @test_setcc_fneg_ole_posk_f32() #0 {
%a = load volatile float, ptr addrspace(1) undef
%x = load volatile i32, ptr addrspace(1) undef
%y = load volatile i32, ptr addrspace(1) undef
%neg.a = fsub float -0.0, %a
%cmp = fcmp ole float %neg.a, 4.0
%select = select i1 %cmp, i32 %x, i32 %y
store volatile i32 %select, ptr addrspace(1) undef
ret void
}
; GCN-LABEL: {{^}}test_setcc_fneg_one_posk_f32:
; GCN: v_cmp_lg_f32_e32 vcc, -4.0, v{{[0-9]+}}
define amdgpu_kernel void @test_setcc_fneg_one_posk_f32() #0 {
%a = load volatile float, ptr addrspace(1) undef
%x = load volatile i32, ptr addrspace(1) undef
%y = load volatile i32, ptr addrspace(1) undef
%neg.a = fsub float -0.0, %a
%cmp = fcmp one float %neg.a, 4.0
%select = select i1 %cmp, i32 %x, i32 %y
store volatile i32 %select, ptr addrspace(1) undef
ret void
}
; GCN-LABEL: {{^}}test_setcc_fneg_ueq_posk_f32:
; GCN: v_cmp_nlg_f32_e32 vcc, -4.0, v{{[0-9]+}}
define amdgpu_kernel void @test_setcc_fneg_ueq_posk_f32() #0 {
%a = load volatile float, ptr addrspace(1) undef
%x = load volatile i32, ptr addrspace(1) undef
%y = load volatile i32, ptr addrspace(1) undef
%neg.a = fsub float -0.0, %a
%cmp = fcmp ueq float %neg.a, 4.0
%select = select i1 %cmp, i32 %x, i32 %y
store volatile i32 %select, ptr addrspace(1) undef
ret void
}
; GCN-LABEL: {{^}}test_setcc_fneg_ugt_posk_f32:
; GCN: v_cmp_nle_f32_e32 vcc, -4.0, v{{[0-9]+}}
define amdgpu_kernel void @test_setcc_fneg_ugt_posk_f32() #0 {
%a = load volatile float, ptr addrspace(1) undef
%x = load volatile i32, ptr addrspace(1) undef
%y = load volatile i32, ptr addrspace(1) undef
%neg.a = fsub float -0.0, %a
%cmp = fcmp ugt float %neg.a, 4.0
%select = select i1 %cmp, i32 %x, i32 %y
store volatile i32 %select, ptr addrspace(1) undef
ret void
}
; GCN-LABEL: {{^}}test_setcc_fneg_uge_posk_f32:
; GCN: v_cmp_nlt_f32_e32 vcc, -4.0, v{{[0-9]+}}
define amdgpu_kernel void @test_setcc_fneg_uge_posk_f32() #0 {
%a = load volatile float, ptr addrspace(1) undef
%x = load volatile i32, ptr addrspace(1) undef
%y = load volatile i32, ptr addrspace(1) undef
%neg.a = fsub float -0.0, %a
%cmp = fcmp uge float %neg.a, 4.0
%select = select i1 %cmp, i32 %x, i32 %y
store volatile i32 %select, ptr addrspace(1) undef
ret void
}
; GCN-LABEL: {{^}}test_setcc_fneg_ult_posk_f32:
; GCN: v_cmp_nge_f32_e32 vcc, -4.0, v{{[0-9]+}}
define amdgpu_kernel void @test_setcc_fneg_ult_posk_f32() #0 {
%a = load volatile float, ptr addrspace(1) undef
%x = load volatile i32, ptr addrspace(1) undef
%y = load volatile i32, ptr addrspace(1) undef
%neg.a = fsub float -0.0, %a
%cmp = fcmp ult float %neg.a, 4.0
%select = select i1 %cmp, i32 %x, i32 %y
store volatile i32 %select, ptr addrspace(1) undef
ret void
}
; GCN-LABEL: {{^}}test_setcc_fneg_ule_posk_f32:
; GCN: v_cmp_ngt_f32_e32 vcc, -4.0, v{{[0-9]+}}
define amdgpu_kernel void @test_setcc_fneg_ule_posk_f32() #0 {
%a = load volatile float, ptr addrspace(1) undef
%x = load volatile i32, ptr addrspace(1) undef
%y = load volatile i32, ptr addrspace(1) undef
%neg.a = fsub float -0.0, %a
%cmp = fcmp ule float %neg.a, 4.0
%select = select i1 %cmp, i32 %x, i32 %y
store volatile i32 %select, ptr addrspace(1) undef
ret void
}
; GCN-LABEL: {{^}}test_setcc_fneg_une_posk_f32:
; GCN: v_cmp_neq_f32_e32 vcc, -4.0, v{{[0-9]+}}
define amdgpu_kernel void @test_setcc_fneg_une_posk_f32() #0 {
%a = load volatile float, ptr addrspace(1) undef
%x = load volatile i32, ptr addrspace(1) undef
%y = load volatile i32, ptr addrspace(1) undef
%neg.a = fsub float -0.0, %a
%cmp = fcmp une float %neg.a, 4.0
%select = select i1 %cmp, i32 %x, i32 %y
store volatile i32 %select, ptr addrspace(1) undef
ret void
}
attributes #0 = { nounwind }
|