1 ;RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck --check-prefix=R600 --check-prefix=FUNC %s 2 ;RUN: llc < %s -march=r600 -mcpu=SI -verify-machineinstrs| FileCheck --check-prefix=SI --check-prefix=FUNC %s 3 4 ; FUNC-LABEL: @setcc_v2i32 5 ; R600-DAG: SETE_INT * T{{[0-9]+\.[XYZW]}}, KC0[3].X, KC0[3].Z 6 ; R600-DAG: SETE_INT * T{{[0-9]+\.[XYZW]}}, KC0[2].W, KC0[3].Y 7 8 define void @setcc_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> %a, <2 x i32> %b) { 9 %result = icmp eq <2 x i32> %a, %b 10 %sext = sext <2 x i1> %result to <2 x i32> 11 store <2 x i32> %sext, <2 x i32> addrspace(1)* %out 12 ret void 13 } 14 15 ; FUNC-LABEL: @setcc_v4i32 16 ; R600-DAG: SETE_INT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} 17 ; R600-DAG: SETE_INT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} 18 ; R600-DAG: SETE_INT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} 19 ; R600-DAG: SETE_INT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} 20 21 define void @setcc_v4i32(<4 x i32> addrspace(1)* %out, <4 x i32> addrspace(1)* %in) { 22 %b_ptr = getelementptr <4 x i32> addrspace(1)* %in, i32 1 23 %a = load <4 x i32> addrspace(1) * %in 24 %b = load <4 x i32> addrspace(1) * %b_ptr 25 %result = icmp eq <4 x i32> %a, %b 26 %sext = sext <4 x i1> %result to <4 x i32> 27 store <4 x i32> %sext, <4 x i32> addrspace(1)* %out 28 ret void 29 } 30 31 ;;;==========================================================================;;; 32 ;; Float comparisons 33 ;;;==========================================================================;;; 34 35 ; FUNC-LABEL: @f32_oeq 36 ; R600: SETE_DX10 37 ; SI: V_CMP_EQ_F32 38 define void @f32_oeq(i32 addrspace(1)* %out, float %a, float %b) { 39 entry: 40 %0 = fcmp oeq float %a, %b 41 %1 = sext i1 %0 to i32 42 store i32 %1, i32 addrspace(1)* %out 43 ret void 44 } 45 46 ; FUNC-LABEL: @f32_ogt 47 ; R600: SETGT_DX10 48 ; SI: V_CMP_GT_F32 49 define void @f32_ogt(i32 addrspace(1)* %out, float %a, float %b) { 50 entry: 51 %0 = fcmp ogt float %a, %b 52 %1 = sext i1 %0 to i32 53 store i32 %1, i32 addrspace(1)* %out 54 ret void 55 } 56 57 ; FUNC-LABEL: @f32_oge 58 ; R600: SETGE_DX10 59 ; SI: V_CMP_GE_F32 60 define void @f32_oge(i32 addrspace(1)* %out, float %a, float %b) { 61 entry: 62 %0 = fcmp oge float %a, %b 63 %1 = sext i1 %0 to i32 64 store i32 %1, i32 addrspace(1)* %out 65 ret void 66 } 67 68 ; FUNC-LABEL: @f32_olt 69 ; R600: SETGT_DX10 70 ; SI: V_CMP_LT_F32 71 define void @f32_olt(i32 addrspace(1)* %out, float %a, float %b) { 72 entry: 73 %0 = fcmp olt float %a, %b 74 %1 = sext i1 %0 to i32 75 store i32 %1, i32 addrspace(1)* %out 76 ret void 77 } 78 79 ; FUNC-LABEL: @f32_ole 80 ; R600: SETGE_DX10 81 ; SI: V_CMP_LE_F32 82 define void @f32_ole(i32 addrspace(1)* %out, float %a, float %b) { 83 entry: 84 %0 = fcmp ole float %a, %b 85 %1 = sext i1 %0 to i32 86 store i32 %1, i32 addrspace(1)* %out 87 ret void 88 } 89 90 ; FUNC-LABEL: @f32_one 91 ; R600-DAG: SETE_DX10 92 ; R600-DAG: SETE_DX10 93 ; R600-DAG: AND_INT 94 ; R600-DAG: SETNE_DX10 95 ; R600-DAG: AND_INT 96 ; R600-DAG: SETNE_INT 97 ; SI: V_CMP_O_F32 98 ; SI: V_CMP_NEQ_F32 99 ; SI: V_CNDMASK_B32_e64 100 ; SI: V_CNDMASK_B32_e64 101 ; SI: V_AND_B32_e32 102 define void @f32_one(i32 addrspace(1)* %out, float %a, float %b) { 103 entry: 104 %0 = fcmp one float %a, %b 105 %1 = sext i1 %0 to i32 106 store i32 %1, i32 addrspace(1)* %out 107 ret void 108 } 109 110 ; FUNC-LABEL: @f32_ord 111 ; R600-DAG: SETE_DX10 112 ; R600-DAG: SETE_DX10 113 ; R600-DAG: AND_INT 114 ; R600-DAG: SETNE_INT 115 ; SI: V_CMP_O_F32 116 define void @f32_ord(i32 addrspace(1)* %out, float %a, float %b) { 117 entry: 118 %0 = fcmp ord float %a, %b 119 %1 = sext i1 %0 to i32 120 store i32 %1, i32 addrspace(1)* %out 121 ret void 122 } 123 124 ; FUNC-LABEL: @f32_ueq 125 ; R600-DAG: SETNE_DX10 126 ; R600-DAG: SETNE_DX10 127 ; R600-DAG: OR_INT 128 ; R600-DAG: SETE_DX10 129 ; R600-DAG: OR_INT 130 ; R600-DAG: SETNE_INT 131 ; SI: V_CMP_U_F32 132 ; SI: V_CMP_EQ_F32 133 ; SI: V_CNDMASK_B32_e64 134 ; SI: V_CNDMASK_B32_e64 135 ; SI: V_OR_B32_e32 136 define void @f32_ueq(i32 addrspace(1)* %out, float %a, float %b) { 137 entry: 138 %0 = fcmp ueq float %a, %b 139 %1 = sext i1 %0 to i32 140 store i32 %1, i32 addrspace(1)* %out 141 ret void 142 } 143 144 ; FUNC-LABEL: @f32_ugt 145 ; R600: SETGE 146 ; R600: SETE_DX10 147 ; SI: V_CMP_U_F32 148 ; SI: V_CMP_GT_F32 149 ; SI: V_CNDMASK_B32_e64 150 ; SI: V_CNDMASK_B32_e64 151 ; SI: V_OR_B32_e32 152 define void @f32_ugt(i32 addrspace(1)* %out, float %a, float %b) { 153 entry: 154 %0 = fcmp ugt float %a, %b 155 %1 = sext i1 %0 to i32 156 store i32 %1, i32 addrspace(1)* %out 157 ret void 158 } 159 160 ; FUNC-LABEL: @f32_uge 161 ; R600: SETGT 162 ; R600: SETE_DX10 163 ; SI: V_CMP_U_F32 164 ; SI: V_CMP_GE_F32 165 ; SI: V_CNDMASK_B32_e64 166 ; SI: V_CNDMASK_B32_e64 167 ; SI: V_OR_B32_e32 168 define void @f32_uge(i32 addrspace(1)* %out, float %a, float %b) { 169 entry: 170 %0 = fcmp uge float %a, %b 171 %1 = sext i1 %0 to i32 172 store i32 %1, i32 addrspace(1)* %out 173 ret void 174 } 175 176 ; FUNC-LABEL: @f32_ult 177 ; R600: SETGE 178 ; R600: SETE_DX10 179 ; SI: V_CMP_U_F32 180 ; SI: V_CMP_LT_F32 181 ; SI: V_CNDMASK_B32_e64 182 ; SI: V_CNDMASK_B32_e64 183 ; SI: V_OR_B32_e32 184 define void @f32_ult(i32 addrspace(1)* %out, float %a, float %b) { 185 entry: 186 %0 = fcmp ult float %a, %b 187 %1 = sext i1 %0 to i32 188 store i32 %1, i32 addrspace(1)* %out 189 ret void 190 } 191 192 ; FUNC-LABEL: @f32_ule 193 ; R600: SETGT 194 ; R600: SETE_DX10 195 ; SI: V_CMP_U_F32 196 ; SI: V_CMP_LE_F32 197 ; SI: V_CNDMASK_B32_e64 198 ; SI: V_CNDMASK_B32_e64 199 ; SI: V_OR_B32_e32 200 define void @f32_ule(i32 addrspace(1)* %out, float %a, float %b) { 201 entry: 202 %0 = fcmp ule float %a, %b 203 %1 = sext i1 %0 to i32 204 store i32 %1, i32 addrspace(1)* %out 205 ret void 206 } 207 208 ; FUNC-LABEL: @f32_une 209 ; R600: SETNE_DX10 210 ; SI: V_CMP_NEQ_F32 211 define void @f32_une(i32 addrspace(1)* %out, float %a, float %b) { 212 entry: 213 %0 = fcmp une float %a, %b 214 %1 = sext i1 %0 to i32 215 store i32 %1, i32 addrspace(1)* %out 216 ret void 217 } 218 219 ; FUNC-LABEL: @f32_uno 220 ; R600: SETNE_DX10 221 ; R600: SETNE_DX10 222 ; R600: OR_INT 223 ; R600: SETNE_INT 224 ; SI: V_CMP_U_F32 225 define void @f32_uno(i32 addrspace(1)* %out, float %a, float %b) { 226 entry: 227 %0 = fcmp uno float %a, %b 228 %1 = sext i1 %0 to i32 229 store i32 %1, i32 addrspace(1)* %out 230 ret void 231 } 232 233 ;;;==========================================================================;;; 234 ;; 32-bit integer comparisons 235 ;;;==========================================================================;;; 236 237 ; FUNC-LABEL: @i32_eq 238 ; R600: SETE_INT 239 ; SI: V_CMP_EQ_I32 240 define void @i32_eq(i32 addrspace(1)* %out, i32 %a, i32 %b) { 241 entry: 242 %0 = icmp eq i32 %a, %b 243 %1 = sext i1 %0 to i32 244 store i32 %1, i32 addrspace(1)* %out 245 ret void 246 } 247 248 ; FUNC-LABEL: @i32_ne 249 ; R600: SETNE_INT 250 ; SI: V_CMP_NE_I32 251 define void @i32_ne(i32 addrspace(1)* %out, i32 %a, i32 %b) { 252 entry: 253 %0 = icmp ne i32 %a, %b 254 %1 = sext i1 %0 to i32 255 store i32 %1, i32 addrspace(1)* %out 256 ret void 257 } 258 259 ; FUNC-LABEL: @i32_ugt 260 ; R600: SETGT_UINT 261 ; SI: V_CMP_GT_U32 262 define void @i32_ugt(i32 addrspace(1)* %out, i32 %a, i32 %b) { 263 entry: 264 %0 = icmp ugt i32 %a, %b 265 %1 = sext i1 %0 to i32 266 store i32 %1, i32 addrspace(1)* %out 267 ret void 268 } 269 270 ; FUNC-LABEL: @i32_uge 271 ; R600: SETGE_UINT 272 ; SI: V_CMP_GE_U32 273 define void @i32_uge(i32 addrspace(1)* %out, i32 %a, i32 %b) { 274 entry: 275 %0 = icmp uge i32 %a, %b 276 %1 = sext i1 %0 to i32 277 store i32 %1, i32 addrspace(1)* %out 278 ret void 279 } 280 281 ; FUNC-LABEL: @i32_ult 282 ; R600: SETGT_UINT 283 ; SI: V_CMP_LT_U32 284 define void @i32_ult(i32 addrspace(1)* %out, i32 %a, i32 %b) { 285 entry: 286 %0 = icmp ult i32 %a, %b 287 %1 = sext i1 %0 to i32 288 store i32 %1, i32 addrspace(1)* %out 289 ret void 290 } 291 292 ; FUNC-LABEL: @i32_ule 293 ; R600: SETGE_UINT 294 ; SI: V_CMP_LE_U32 295 define void @i32_ule(i32 addrspace(1)* %out, i32 %a, i32 %b) { 296 entry: 297 %0 = icmp ule i32 %a, %b 298 %1 = sext i1 %0 to i32 299 store i32 %1, i32 addrspace(1)* %out 300 ret void 301 } 302 303 ; FUNC-LABEL: @i32_sgt 304 ; R600: SETGT_INT 305 ; SI: V_CMP_GT_I32 306 define void @i32_sgt(i32 addrspace(1)* %out, i32 %a, i32 %b) { 307 entry: 308 %0 = icmp sgt i32 %a, %b 309 %1 = sext i1 %0 to i32 310 store i32 %1, i32 addrspace(1)* %out 311 ret void 312 } 313 314 ; FUNC-LABEL: @i32_sge 315 ; R600: SETGE_INT 316 ; SI: V_CMP_GE_I32 317 define void @i32_sge(i32 addrspace(1)* %out, i32 %a, i32 %b) { 318 entry: 319 %0 = icmp sge i32 %a, %b 320 %1 = sext i1 %0 to i32 321 store i32 %1, i32 addrspace(1)* %out 322 ret void 323 } 324 325 ; FUNC-LABEL: @i32_slt 326 ; R600: SETGT_INT 327 ; SI: V_CMP_LT_I32 328 define void @i32_slt(i32 addrspace(1)* %out, i32 %a, i32 %b) { 329 entry: 330 %0 = icmp slt i32 %a, %b 331 %1 = sext i1 %0 to i32 332 store i32 %1, i32 addrspace(1)* %out 333 ret void 334 } 335 336 ; FUNC-LABEL: @i32_sle 337 ; R600: SETGE_INT 338 ; SI: V_CMP_LE_I32 339 define void @i32_sle(i32 addrspace(1)* %out, i32 %a, i32 %b) { 340 entry: 341 %0 = icmp sle i32 %a, %b 342 %1 = sext i1 %0 to i32 343 store i32 %1, i32 addrspace(1)* %out 344 ret void 345 } 346