1//===-- SIInstructions.td - SI Instruction Definitions --------------------===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8// This file was originally auto-generated from a GPU register header file and 9// all the instruction definitions were originally commented out. Instructions 10// that are not yet supported remain commented out. 11//===----------------------------------------------------------------------===// 12 13class GCNPat<dag pattern, dag result> : Pat<pattern, result>, GCNPredicateControl { 14 15} 16 17class UniformSextInreg<ValueType VT> : PatFrag< 18 (ops node:$src), 19 (sext_inreg $src, VT), 20 [{ return !N->isDivergent(); }]>; 21 22class DivergentSextInreg<ValueType VT> : PatFrag< 23 (ops node:$src), 24 (sext_inreg $src, VT), 25 [{ return N->isDivergent(); }]>; 26 27include "SOPInstructions.td" 28include "VOPInstructions.td" 29include "SMInstructions.td" 30include "FLATInstructions.td" 31include "BUFInstructions.td" 32include "EXPInstructions.td" 33include "LDSDIRInstructions.td" 34include "VINTERPInstructions.td" 35 36//===----------------------------------------------------------------------===// 37// VINTRP Instructions 38//===----------------------------------------------------------------------===// 39 40// Used to inject printing of "_e32" suffix for VI (there are "_e64" variants for VI) 41def VINTRPDst : VINTRPDstOperand <VGPR_32>; 42 43let Uses = [MODE, M0, EXEC] in { 44 45// FIXME: Specify SchedRW for VINTRP instructions. 46 47multiclass V_INTERP_P1_F32_m : VINTRP_m < 48 0x00000000, 49 (outs VINTRPDst:$vdst), 50 (ins VGPR_32:$vsrc, Attr:$attr, AttrChan:$attrchan), 51 "v_interp_p1_f32$vdst, $vsrc, $attr$attrchan", 52 [(set f32:$vdst, (int_amdgcn_interp_p1 f32:$vsrc, 53 (i32 timm:$attrchan), (i32 timm:$attr), M0))] 54>; 55 56let OtherPredicates = [has32BankLDS, isNotGFX90APlus] in { 57 58defm V_INTERP_P1_F32 : V_INTERP_P1_F32_m; 59 60} // End OtherPredicates = [has32BankLDS, isNotGFX90APlus] 61 62let OtherPredicates = [has16BankLDS, isNotGFX90APlus], 63 Constraints = "@earlyclobber $vdst", isAsmParserOnly=1 in { 64 65defm V_INTERP_P1_F32_16bank : V_INTERP_P1_F32_m; 66 67} // End OtherPredicates = [has32BankLDS, isNotGFX90APlus], 68 // Constraints = "@earlyclobber $vdst", isAsmParserOnly=1 69 70let OtherPredicates = [isNotGFX90APlus] in { 71let DisableEncoding = "$src0", Constraints = "$src0 = $vdst" in { 72 73defm V_INTERP_P2_F32 : VINTRP_m < 74 0x00000001, 75 (outs VINTRPDst:$vdst), 76 (ins VGPR_32:$src0, VGPR_32:$vsrc, Attr:$attr, AttrChan:$attrchan), 77 "v_interp_p2_f32$vdst, $vsrc, $attr$attrchan", 78 [(set f32:$vdst, (int_amdgcn_interp_p2 f32:$src0, f32:$vsrc, 79 (i32 timm:$attrchan), (i32 timm:$attr), M0))]>; 80 81} // End DisableEncoding = "$src0", Constraints = "$src0 = $vdst" 82 83defm V_INTERP_MOV_F32 : VINTRP_m < 84 0x00000002, 85 (outs VINTRPDst:$vdst), 86 (ins InterpSlot:$vsrc, Attr:$attr, AttrChan:$attrchan), 87 "v_interp_mov_f32$vdst, $vsrc, $attr$attrchan", 88 [(set f32:$vdst, (int_amdgcn_interp_mov (i32 timm:$vsrc), 89 (i32 timm:$attrchan), (i32 timm:$attr), M0))]>; 90 91} // End OtherPredicates = [isNotGFX90APlus] 92 93} // End Uses = [MODE, M0, EXEC] 94 95//===----------------------------------------------------------------------===// 96// Pseudo Instructions 97//===----------------------------------------------------------------------===// 98def ATOMIC_FENCE : SPseudoInstSI< 99 (outs), (ins i32imm:$ordering, i32imm:$scope), 100 [(atomic_fence (i32 timm:$ordering), (i32 timm:$scope))], 101 "ATOMIC_FENCE $ordering, $scope"> { 102 let hasSideEffects = 1; 103 let maybeAtomic = 1; 104} 105 106let hasSideEffects = 0, mayLoad = 0, mayStore = 0, Uses = [EXEC] in { 107 108// For use in patterns 109def V_CNDMASK_B64_PSEUDO : VOP3Common <(outs VReg_64:$vdst), 110 (ins VSrc_b64:$src0, VSrc_b64:$src1, SSrc_b64:$src2), "", []> { 111 let isPseudo = 1; 112 let isCodeGenOnly = 1; 113 let usesCustomInserter = 1; 114} 115 116// 64-bit vector move instruction. This is mainly used by the 117// SIFoldOperands pass to enable folding of inline immediates. 118def V_MOV_B64_PSEUDO : VPseudoInstSI <(outs VReg_64:$vdst), 119 (ins VSrc_b64:$src0)> { 120 let isReMaterializable = 1; 121 let isAsCheapAsAMove = 1; 122 let isMoveImm = 1; 123 let SchedRW = [Write64Bit]; 124 let Size = 16; // Needs maximum 2 v_mov_b32 instructions 8 byte long each. 125} 126 127// 64-bit vector move with dpp. Expanded post-RA. 128def V_MOV_B64_DPP_PSEUDO : VOP_DPP_Pseudo <"v_mov_b64_dpp", VOP_I64_I64> { 129 let Size = 16; // Requires two 8-byte v_mov_b32_dpp to complete. 130} 131 132// 64-bit scalar move immediate instruction. This is used to avoid subregs 133// initialization and allow rematerialization. 134def S_MOV_B64_IMM_PSEUDO : SPseudoInstSI <(outs SReg_64:$sdst), 135 (ins i64imm:$src0)> { 136 let isReMaterializable = 1; 137 let isAsCheapAsAMove = 1; 138 let isMoveImm = 1; 139 let SchedRW = [WriteSALU, Write64Bit]; 140 let Size = 16; // Needs maximum 2 s_mov_b32 instructions 8 byte long each. 141 let Uses = []; 142} 143 144// Pseudoinstruction for @llvm.amdgcn.wqm. It is turned into a copy after the 145// WQM pass processes it. 146def WQM : PseudoInstSI <(outs unknown:$vdst), (ins unknown:$src0)>; 147 148// Pseudoinstruction for @llvm.amdgcn.softwqm. Like @llvm.amdgcn.wqm it is 149// turned into a copy by WQM pass, but does not seed WQM requirements. 150def SOFT_WQM : PseudoInstSI <(outs unknown:$vdst), (ins unknown:$src0)>; 151 152// Pseudoinstruction for @llvm.amdgcn.strict.wwm. It is turned into a copy post-RA, so 153// that the @earlyclobber is respected. The @earlyclobber is to make sure that 154// the instruction that defines $src0 (which is run in Whole Wave Mode) doesn't 155// accidentally clobber inactive channels of $vdst. 156let Constraints = "@earlyclobber $vdst" in { 157def STRICT_WWM : PseudoInstSI <(outs unknown:$vdst), (ins unknown:$src0)>; 158def STRICT_WQM : PseudoInstSI <(outs unknown:$vdst), (ins unknown:$src0)>; 159} 160 161} // End let hasSideEffects = 0, mayLoad = 0, mayStore = 0, Uses = [EXEC] 162 163def ENTER_STRICT_WWM : SPseudoInstSI <(outs SReg_1:$sdst), (ins i64imm:$src0)> { 164 let Uses = [EXEC]; 165 let Defs = [EXEC, SCC]; 166 let hasSideEffects = 0; 167 let mayLoad = 0; 168 let mayStore = 0; 169} 170 171def EXIT_STRICT_WWM : SPseudoInstSI <(outs SReg_1:$sdst), (ins SReg_1:$src0)> { 172 let hasSideEffects = 0; 173 let mayLoad = 0; 174 let mayStore = 0; 175} 176 177def ENTER_STRICT_WQM : SPseudoInstSI <(outs SReg_1:$sdst), (ins i64imm:$src0)> { 178 let Uses = [EXEC]; 179 let Defs = [EXEC, SCC]; 180 let hasSideEffects = 0; 181 let mayLoad = 0; 182 let mayStore = 0; 183} 184 185def EXIT_STRICT_WQM : SPseudoInstSI <(outs SReg_1:$sdst), (ins SReg_1:$src0)> { 186 let hasSideEffects = 0; 187 let mayLoad = 0; 188 let mayStore = 0; 189} 190 191// Pseudo instructions used for @llvm.fptrunc.round upward 192// and @llvm.fptrunc.round downward. 193// These intrinsics will be legalized to G_FPTRUNC_ROUND_UPWARD 194// and G_FPTRUNC_ROUND_DOWNWARD before being lowered to 195// FPTRUNC_UPWARD_PSEUDO and FPTRUNC_DOWNWARD_PSEUDO. 196// The final codegen is done in the ModeRegister pass. 197let Uses = [MODE, EXEC] in { 198def FPTRUNC_UPWARD_PSEUDO : VPseudoInstSI <(outs VGPR_32:$vdst), 199 (ins VGPR_32:$src0), 200 [(set f16:$vdst, (SIfptrunc_round_upward f32:$src0))]>; 201 202def FPTRUNC_DOWNWARD_PSEUDO : VPseudoInstSI <(outs VGPR_32:$vdst), 203 (ins VGPR_32:$src0), 204 [(set f16:$vdst, (SIfptrunc_round_downward f32:$src0))]>; 205} // End Uses = [MODE, EXEC] 206 207// Invert the exec mask and overwrite the inactive lanes of dst with inactive, 208// restoring it after we're done. 209let Defs = [SCC] in { 210def V_SET_INACTIVE_B32 : VPseudoInstSI <(outs VGPR_32:$vdst), 211 (ins VSrc_b32: $src, VSrc_b32:$inactive), 212 [(set i32:$vdst, (int_amdgcn_set_inactive i32:$src, i32:$inactive))]> { 213} 214 215def V_SET_INACTIVE_B64 : VPseudoInstSI <(outs VReg_64:$vdst), 216 (ins VSrc_b64: $src, VSrc_b64:$inactive), 217 [(set i64:$vdst, (int_amdgcn_set_inactive i64:$src, i64:$inactive))]> { 218} 219} // End Defs = [SCC] 220 221let usesCustomInserter = 1, Defs = [VCC, EXEC] in { 222def V_ADD_U64_PSEUDO : VPseudoInstSI < 223 (outs VReg_64:$vdst), (ins VSrc_b64:$src0, VSrc_b64:$src1), 224 [(set VReg_64:$vdst, (getDivergentFrag<add>.ret i64:$src0, i64:$src1))] 225>; 226 227def V_SUB_U64_PSEUDO : VPseudoInstSI < 228 (outs VReg_64:$vdst), (ins VSrc_b64:$src0, VSrc_b64:$src1), 229 [(set VReg_64:$vdst, (getDivergentFrag<sub>.ret i64:$src0, i64:$src1))] 230>; 231} // End usesCustomInserter = 1, Defs = [VCC, EXEC] 232 233let usesCustomInserter = 1, Defs = [SCC] in { 234def S_ADD_U64_PSEUDO : SPseudoInstSI < 235 (outs SReg_64:$sdst), (ins SSrc_b64:$src0, SSrc_b64:$src1), 236 [(set SReg_64:$sdst, (UniformBinFrag<add> i64:$src0, i64:$src1))] 237>; 238 239def S_SUB_U64_PSEUDO : SPseudoInstSI < 240 (outs SReg_64:$sdst), (ins SSrc_b64:$src0, SSrc_b64:$src1), 241 [(set SReg_64:$sdst, (UniformBinFrag<sub> i64:$src0, i64:$src1))] 242>; 243 244def S_ADD_U64_CO_PSEUDO : SPseudoInstSI < 245 (outs SReg_64:$vdst, VOPDstS64orS32:$sdst), (ins SSrc_b64:$src0, SSrc_b64:$src1) 246>; 247 248def S_SUB_U64_CO_PSEUDO : SPseudoInstSI < 249 (outs SReg_64:$vdst, VOPDstS64orS32:$sdst), (ins SSrc_b64:$src0, SSrc_b64:$src1) 250>; 251 252def S_ADD_CO_PSEUDO : SPseudoInstSI < 253 (outs SReg_32:$sdst, SSrc_i1:$scc_out), (ins SSrc_b32:$src0, SSrc_b32:$src1, SSrc_i1:$scc_in) 254>; 255 256def S_SUB_CO_PSEUDO : SPseudoInstSI < 257 (outs SReg_32:$sdst, SSrc_i1:$scc_out), (ins SSrc_b32:$src0, SSrc_b32:$src1, SSrc_i1:$scc_in) 258>; 259 260def S_UADDO_PSEUDO : SPseudoInstSI < 261 (outs SReg_32:$sdst, SSrc_i1:$scc_out), (ins SSrc_b32:$src0, SSrc_b32:$src1) 262>; 263 264def S_USUBO_PSEUDO : SPseudoInstSI < 265 (outs SReg_32:$sdst, SSrc_i1:$scc_out), (ins SSrc_b32:$src0, SSrc_b32:$src1) 266>; 267 268} // End usesCustomInserter = 1, Defs = [SCC] 269 270let usesCustomInserter = 1 in { 271def GET_GROUPSTATICSIZE : SPseudoInstSI <(outs SReg_32:$sdst), (ins), 272 [(set SReg_32:$sdst, (int_amdgcn_groupstaticsize))]>; 273} // End let usesCustomInserter = 1, SALU = 1 274 275// Wrap an instruction by duplicating it, except for setting isTerminator. 276class WrapTerminatorInst<SOP_Pseudo base_inst> : SPseudoInstSI< 277 base_inst.OutOperandList, 278 base_inst.InOperandList> { 279 let Uses = base_inst.Uses; 280 let Defs = base_inst.Defs; 281 let isTerminator = 1; 282 let isAsCheapAsAMove = base_inst.isAsCheapAsAMove; 283 let hasSideEffects = base_inst.hasSideEffects; 284 let UseNamedOperandTable = base_inst.UseNamedOperandTable; 285 let CodeSize = base_inst.CodeSize; 286 let SchedRW = base_inst.SchedRW; 287} 288 289let WaveSizePredicate = isWave64 in { 290def S_MOV_B64_term : WrapTerminatorInst<S_MOV_B64>; 291def S_XOR_B64_term : WrapTerminatorInst<S_XOR_B64>; 292def S_OR_B64_term : WrapTerminatorInst<S_OR_B64>; 293def S_ANDN2_B64_term : WrapTerminatorInst<S_ANDN2_B64>; 294def S_AND_B64_term : WrapTerminatorInst<S_AND_B64>; 295} 296 297let WaveSizePredicate = isWave32 in { 298def S_MOV_B32_term : WrapTerminatorInst<S_MOV_B32>; 299def S_XOR_B32_term : WrapTerminatorInst<S_XOR_B32>; 300def S_OR_B32_term : WrapTerminatorInst<S_OR_B32>; 301def S_ANDN2_B32_term : WrapTerminatorInst<S_ANDN2_B32>; 302def S_AND_B32_term : WrapTerminatorInst<S_AND_B32>; 303} 304 305 306def WAVE_BARRIER : SPseudoInstSI<(outs), (ins), 307 [(int_amdgcn_wave_barrier)]> { 308 let SchedRW = []; 309 let hasNoSchedulingInfo = 1; 310 let hasSideEffects = 1; 311 let mayLoad = 0; 312 let mayStore = 0; 313 let isConvergent = 1; 314 let FixedSize = 1; 315 let Size = 0; 316 let isMeta = 1; 317} 318 319def SCHED_BARRIER : SPseudoInstSI<(outs), (ins i32imm:$mask), 320 [(int_amdgcn_sched_barrier (i32 timm:$mask))]> { 321 let SchedRW = []; 322 let hasNoSchedulingInfo = 1; 323 let hasSideEffects = 1; 324 let mayLoad = 0; 325 let mayStore = 0; 326 let isConvergent = 1; 327 let FixedSize = 1; 328 let Size = 0; 329 let isMeta = 1; 330} 331 332// SI pseudo instructions. These are used by the CFG structurizer pass 333// and should be lowered to ISA instructions prior to codegen. 334 335let isTerminator = 1 in { 336 337let OtherPredicates = [EnableLateCFGStructurize] in { 338 def SI_NON_UNIFORM_BRCOND_PSEUDO : CFPseudoInstSI < 339 (outs), 340 (ins SReg_1:$vcc, brtarget:$target), 341 [(brcond i1:$vcc, bb:$target)]> { 342 let Size = 12; 343} 344} 345 346def SI_IF: CFPseudoInstSI < 347 (outs SReg_1:$dst), (ins SReg_1:$vcc, brtarget:$target), 348 [(set i1:$dst, (AMDGPUif i1:$vcc, bb:$target))], 1, 1> { 349 let Constraints = ""; 350 let Size = 12; 351 let hasSideEffects = 1; 352} 353 354def SI_ELSE : CFPseudoInstSI < 355 (outs SReg_1:$dst), 356 (ins SReg_1:$src, brtarget:$target), [], 1, 1> { 357 let Size = 12; 358 let hasSideEffects = 1; 359} 360 361def SI_WATERFALL_LOOP : CFPseudoInstSI < 362 (outs), 363 (ins brtarget:$target), [], 1> { 364 let Size = 8; 365 let isBranch = 1; 366 let Defs = []; 367} 368 369def SI_LOOP : CFPseudoInstSI < 370 (outs), (ins SReg_1:$saved, brtarget:$target), 371 [(AMDGPUloop i1:$saved, bb:$target)], 1, 1> { 372 let Size = 8; 373 let isBranch = 1; 374 let hasSideEffects = 1; 375} 376 377} // End isTerminator = 1 378 379def SI_END_CF : CFPseudoInstSI < 380 (outs), (ins SReg_1:$saved), [], 1, 1> { 381 let Size = 4; 382 let isAsCheapAsAMove = 1; 383 let isReMaterializable = 1; 384 let hasSideEffects = 1; 385 let mayLoad = 1; // FIXME: Should not need memory flags 386 let mayStore = 1; 387} 388 389def SI_IF_BREAK : CFPseudoInstSI < 390 (outs SReg_1:$dst), (ins SReg_1:$vcc, SReg_1:$src), []> { 391 let Size = 4; 392 let isAsCheapAsAMove = 1; 393 let isReMaterializable = 1; 394} 395 396// Branch to the early termination block of the shader if SCC is 0. 397// This uses SCC from a previous SALU operation, i.e. the update of 398// a mask of live lanes after a kill/demote operation. 399// Only valid in pixel shaders. 400def SI_EARLY_TERMINATE_SCC0 : SPseudoInstSI <(outs), (ins)> { 401 let Uses = [EXEC,SCC]; 402} 403 404let Uses = [EXEC] in { 405 406multiclass PseudoInstKill <dag ins> { 407 // Even though this pseudo can usually be expanded without an SCC def, we 408 // conservatively assume that it has an SCC def, both because it is sometimes 409 // required in degenerate cases (when V_CMPX cannot be used due to constant 410 // bus limitations) and because it allows us to avoid having to track SCC 411 // liveness across basic blocks. 412 let Defs = [EXEC,SCC] in 413 def _PSEUDO : PseudoInstSI <(outs), ins> { 414 let isConvergent = 1; 415 let usesCustomInserter = 1; 416 } 417 418 let Defs = [EXEC,SCC] in 419 def _TERMINATOR : SPseudoInstSI <(outs), ins> { 420 let isTerminator = 1; 421 } 422} 423 424defm SI_KILL_I1 : PseudoInstKill <(ins SCSrc_i1:$src, i1imm:$killvalue)>; 425let Defs = [VCC] in 426defm SI_KILL_F32_COND_IMM : PseudoInstKill <(ins VSrc_b32:$src0, i32imm:$src1, i32imm:$cond)>; 427 428let Defs = [EXEC,VCC] in 429def SI_ILLEGAL_COPY : SPseudoInstSI < 430 (outs unknown:$dst), (ins unknown:$src), 431 [], " ; illegal copy $src to $dst">; 432 433} // End Uses = [EXEC], Defs = [EXEC,VCC] 434 435// Branch on undef scc. Used to avoid intermediate copy from 436// IMPLICIT_DEF to SCC. 437def SI_BR_UNDEF : SPseudoInstSI <(outs), (ins sopp_brtarget:$simm16)> { 438 let isTerminator = 1; 439 let usesCustomInserter = 1; 440 let isBranch = 1; 441} 442 443def SI_PS_LIVE : PseudoInstSI < 444 (outs SReg_1:$dst), (ins), 445 [(set i1:$dst, (int_amdgcn_ps_live))]> { 446 let SALU = 1; 447} 448 449let Uses = [EXEC] in { 450def SI_LIVE_MASK : PseudoInstSI < 451 (outs SReg_1:$dst), (ins), 452 [(set i1:$dst, (int_amdgcn_live_mask))]> { 453 let SALU = 1; 454} 455let Defs = [EXEC,SCC] in { 456// Demote: Turn a pixel shader thread into a helper lane. 457def SI_DEMOTE_I1 : SPseudoInstSI <(outs), (ins SCSrc_i1:$src, i1imm:$killvalue)>; 458} // End Defs = [EXEC,SCC] 459} // End Uses = [EXEC] 460 461def SI_MASKED_UNREACHABLE : SPseudoInstSI <(outs), (ins), 462 [(int_amdgcn_unreachable)], 463 "; divergent unreachable"> { 464 let Size = 0; 465 let hasNoSchedulingInfo = 1; 466 let FixedSize = 1; 467 let isMeta = 1; 468} 469 470// Used as an isel pseudo to directly emit initialization with an 471// s_mov_b32 rather than a copy of another initialized 472// register. MachineCSE skips copies, and we don't want to have to 473// fold operands before it runs. 474def SI_INIT_M0 : SPseudoInstSI <(outs), (ins SSrc_b32:$src)> { 475 let Defs = [M0]; 476 let usesCustomInserter = 1; 477 let isAsCheapAsAMove = 1; 478 let isReMaterializable = 1; 479} 480 481def SI_INIT_EXEC : SPseudoInstSI < 482 (outs), (ins i64imm:$src), 483 [(int_amdgcn_init_exec (i64 timm:$src))]> { 484 let Defs = [EXEC]; 485 let isAsCheapAsAMove = 1; 486} 487 488def SI_INIT_EXEC_FROM_INPUT : SPseudoInstSI < 489 (outs), (ins SSrc_b32:$input, i32imm:$shift), 490 [(int_amdgcn_init_exec_from_input i32:$input, (i32 timm:$shift))]> { 491 let Defs = [EXEC]; 492} 493 494// Return for returning shaders to a shader variant epilog. 495def SI_RETURN_TO_EPILOG : SPseudoInstSI < 496 (outs), (ins variable_ops), [(AMDGPUreturn_to_epilog)]> { 497 let isTerminator = 1; 498 let isBarrier = 1; 499 let isReturn = 1; 500 let hasNoSchedulingInfo = 1; 501 let DisableWQM = 1; 502 let FixedSize = 1; 503 504 // TODO: Should this be true? 505 let isMeta = 0; 506} 507 508// Return for returning function calls. 509def SI_RETURN : SPseudoInstSI < 510 (outs), (ins), [(AMDGPUret_flag)], 511 "; return"> { 512 let isTerminator = 1; 513 let isBarrier = 1; 514 let isReturn = 1; 515 let SchedRW = [WriteBranch]; 516} 517 518// Return for returning function calls without output register. 519// 520// This version is only needed so we can fill in the output register 521// in the custom inserter. 522def SI_CALL_ISEL : SPseudoInstSI < 523 (outs), (ins SSrc_b64:$src0, unknown:$callee), 524 [(AMDGPUcall i64:$src0, tglobaladdr:$callee)]> { 525 let Size = 4; 526 let isCall = 1; 527 let SchedRW = [WriteBranch]; 528 let usesCustomInserter = 1; 529 // TODO: Should really base this on the call target 530 let isConvergent = 1; 531} 532 533def : GCNPat< 534 (AMDGPUcall i64:$src0, (i64 0)), 535 (SI_CALL_ISEL $src0, (i64 0)) 536>; 537 538// Wrapper around s_swappc_b64 with extra $callee parameter to track 539// the called function after regalloc. 540def SI_CALL : SPseudoInstSI < 541 (outs SReg_64:$dst), (ins SSrc_b64:$src0, unknown:$callee)> { 542 let Size = 4; 543 let FixedSize = 1; 544 let isCall = 1; 545 let UseNamedOperandTable = 1; 546 let SchedRW = [WriteBranch]; 547 // TODO: Should really base this on the call target 548 let isConvergent = 1; 549} 550 551// Tail call handling pseudo 552def SI_TCRETURN : SPseudoInstSI <(outs), 553 (ins SReg_64:$src0, unknown:$callee, i32imm:$fpdiff), 554 [(AMDGPUtc_return i64:$src0, tglobaladdr:$callee, i32:$fpdiff)]> { 555 let Size = 4; 556 let FixedSize = 1; 557 let isCall = 1; 558 let isTerminator = 1; 559 let isReturn = 1; 560 let isBarrier = 1; 561 let UseNamedOperandTable = 1; 562 let SchedRW = [WriteBranch]; 563 // TODO: Should really base this on the call target 564 let isConvergent = 1; 565} 566 567// Handle selecting indirect tail calls 568def : GCNPat< 569 (AMDGPUtc_return i64:$src0, (i64 0), (i32 timm:$fpdiff)), 570 (SI_TCRETURN SReg_64:$src0, (i64 0), i32imm:$fpdiff) 571>; 572 573def ADJCALLSTACKUP : SPseudoInstSI< 574 (outs), (ins i32imm:$amt0, i32imm:$amt1), 575 [(callseq_start timm:$amt0, timm:$amt1)], 576 "; adjcallstackup $amt0 $amt1"> { 577 let Size = 8; // Worst case. (s_add_u32 + constant) 578 let FixedSize = 1; 579 let hasSideEffects = 1; 580 let usesCustomInserter = 1; 581 let SchedRW = [WriteSALU]; 582 let Defs = [SCC]; 583} 584 585def ADJCALLSTACKDOWN : SPseudoInstSI< 586 (outs), (ins i32imm:$amt1, i32imm:$amt2), 587 [(callseq_end timm:$amt1, timm:$amt2)], 588 "; adjcallstackdown $amt1"> { 589 let Size = 8; // Worst case. (s_add_u32 + constant) 590 let hasSideEffects = 1; 591 let usesCustomInserter = 1; 592 let SchedRW = [WriteSALU]; 593 let Defs = [SCC]; 594} 595 596let Defs = [M0, EXEC, SCC], 597 UseNamedOperandTable = 1 in { 598 599// SI_INDIRECT_SRC/DST are only used by legacy SelectionDAG indirect 600// addressing implementation. 601class SI_INDIRECT_SRC<RegisterClass rc> : VPseudoInstSI < 602 (outs VGPR_32:$vdst), 603 (ins rc:$src, VS_32:$idx, i32imm:$offset)> { 604 let usesCustomInserter = 1; 605} 606 607class SI_INDIRECT_DST<RegisterClass rc> : VPseudoInstSI < 608 (outs rc:$vdst), 609 (ins rc:$src, VS_32:$idx, i32imm:$offset, VGPR_32:$val)> { 610 let Constraints = "$src = $vdst"; 611 let usesCustomInserter = 1; 612} 613 614def SI_INDIRECT_SRC_V1 : SI_INDIRECT_SRC<VGPR_32>; 615def SI_INDIRECT_SRC_V2 : SI_INDIRECT_SRC<VReg_64>; 616def SI_INDIRECT_SRC_V4 : SI_INDIRECT_SRC<VReg_128>; 617def SI_INDIRECT_SRC_V8 : SI_INDIRECT_SRC<VReg_256>; 618def SI_INDIRECT_SRC_V16 : SI_INDIRECT_SRC<VReg_512>; 619def SI_INDIRECT_SRC_V32 : SI_INDIRECT_SRC<VReg_1024>; 620 621def SI_INDIRECT_DST_V1 : SI_INDIRECT_DST<VGPR_32>; 622def SI_INDIRECT_DST_V2 : SI_INDIRECT_DST<VReg_64>; 623def SI_INDIRECT_DST_V4 : SI_INDIRECT_DST<VReg_128>; 624def SI_INDIRECT_DST_V8 : SI_INDIRECT_DST<VReg_256>; 625def SI_INDIRECT_DST_V16 : SI_INDIRECT_DST<VReg_512>; 626def SI_INDIRECT_DST_V32 : SI_INDIRECT_DST<VReg_1024>; 627 628} // End Uses = [EXEC], Defs = [M0, EXEC] 629 630// This is a pseudo variant of the v_movreld_b32 instruction in which the 631// vector operand appears only twice, once as def and once as use. Using this 632// pseudo avoids problems with the Two Address instructions pass. 633class INDIRECT_REG_WRITE_MOVREL_pseudo<RegisterClass rc, 634 RegisterOperand val_ty> : PseudoInstSI < 635 (outs rc:$vdst), (ins rc:$vsrc, val_ty:$val, i32imm:$subreg)> { 636 let Constraints = "$vsrc = $vdst"; 637 let Uses = [M0]; 638} 639 640class V_INDIRECT_REG_WRITE_MOVREL_B32_pseudo<RegisterClass rc> : 641 INDIRECT_REG_WRITE_MOVREL_pseudo<rc, VSrc_b32> { 642 let VALU = 1; 643 let VOP1 = 1; 644 let Uses = [M0, EXEC]; 645} 646 647class S_INDIRECT_REG_WRITE_MOVREL_pseudo<RegisterClass rc, 648 RegisterOperand val_ty> : 649 INDIRECT_REG_WRITE_MOVREL_pseudo<rc, val_ty> { 650 let SALU = 1; 651 let SOP1 = 1; 652 let Uses = [M0]; 653} 654 655class S_INDIRECT_REG_WRITE_MOVREL_B32_pseudo<RegisterClass rc> : 656 S_INDIRECT_REG_WRITE_MOVREL_pseudo<rc, SSrc_b32>; 657class S_INDIRECT_REG_WRITE_MOVREL_B64_pseudo<RegisterClass rc> : 658 S_INDIRECT_REG_WRITE_MOVREL_pseudo<rc, SSrc_b64>; 659 660def V_INDIRECT_REG_WRITE_MOVREL_B32_V1 : V_INDIRECT_REG_WRITE_MOVREL_B32_pseudo<VGPR_32>; 661def V_INDIRECT_REG_WRITE_MOVREL_B32_V2 : V_INDIRECT_REG_WRITE_MOVREL_B32_pseudo<VReg_64>; 662def V_INDIRECT_REG_WRITE_MOVREL_B32_V3 : V_INDIRECT_REG_WRITE_MOVREL_B32_pseudo<VReg_96>; 663def V_INDIRECT_REG_WRITE_MOVREL_B32_V4 : V_INDIRECT_REG_WRITE_MOVREL_B32_pseudo<VReg_128>; 664def V_INDIRECT_REG_WRITE_MOVREL_B32_V5 : V_INDIRECT_REG_WRITE_MOVREL_B32_pseudo<VReg_160>; 665def V_INDIRECT_REG_WRITE_MOVREL_B32_V8 : V_INDIRECT_REG_WRITE_MOVREL_B32_pseudo<VReg_256>; 666def V_INDIRECT_REG_WRITE_MOVREL_B32_V16 : V_INDIRECT_REG_WRITE_MOVREL_B32_pseudo<VReg_512>; 667def V_INDIRECT_REG_WRITE_MOVREL_B32_V32 : V_INDIRECT_REG_WRITE_MOVREL_B32_pseudo<VReg_1024>; 668 669def S_INDIRECT_REG_WRITE_MOVREL_B32_V1 : S_INDIRECT_REG_WRITE_MOVREL_B32_pseudo<SReg_32>; 670def S_INDIRECT_REG_WRITE_MOVREL_B32_V2 : S_INDIRECT_REG_WRITE_MOVREL_B32_pseudo<SReg_64>; 671def S_INDIRECT_REG_WRITE_MOVREL_B32_V3 : S_INDIRECT_REG_WRITE_MOVREL_B32_pseudo<SReg_96>; 672def S_INDIRECT_REG_WRITE_MOVREL_B32_V4 : S_INDIRECT_REG_WRITE_MOVREL_B32_pseudo<SReg_128>; 673def S_INDIRECT_REG_WRITE_MOVREL_B32_V5 : S_INDIRECT_REG_WRITE_MOVREL_B32_pseudo<SReg_160>; 674def S_INDIRECT_REG_WRITE_MOVREL_B32_V8 : S_INDIRECT_REG_WRITE_MOVREL_B32_pseudo<SReg_256>; 675def S_INDIRECT_REG_WRITE_MOVREL_B32_V16 : S_INDIRECT_REG_WRITE_MOVREL_B32_pseudo<SReg_512>; 676def S_INDIRECT_REG_WRITE_MOVREL_B32_V32 : S_INDIRECT_REG_WRITE_MOVREL_B32_pseudo<SReg_1024>; 677 678def S_INDIRECT_REG_WRITE_MOVREL_B64_V1 : S_INDIRECT_REG_WRITE_MOVREL_B64_pseudo<SReg_64>; 679def S_INDIRECT_REG_WRITE_MOVREL_B64_V2 : S_INDIRECT_REG_WRITE_MOVREL_B64_pseudo<SReg_128>; 680def S_INDIRECT_REG_WRITE_MOVREL_B64_V4 : S_INDIRECT_REG_WRITE_MOVREL_B64_pseudo<SReg_256>; 681def S_INDIRECT_REG_WRITE_MOVREL_B64_V8 : S_INDIRECT_REG_WRITE_MOVREL_B64_pseudo<SReg_512>; 682def S_INDIRECT_REG_WRITE_MOVREL_B64_V16 : S_INDIRECT_REG_WRITE_MOVREL_B64_pseudo<SReg_1024>; 683 684// These variants of V_INDIRECT_REG_READ/WRITE use VGPR indexing. By using these 685// pseudos we avoid spills or copies being inserted within indirect sequences 686// that switch the VGPR indexing mode. Spills to accvgprs could be effected by 687// this mode switching. 688 689class V_INDIRECT_REG_WRITE_GPR_IDX_pseudo<RegisterClass rc> : PseudoInstSI < 690 (outs rc:$vdst), (ins rc:$vsrc, VSrc_b32:$val, SSrc_b32:$idx, i32imm:$subreg)> { 691 let Constraints = "$vsrc = $vdst"; 692 let VALU = 1; 693 let Uses = [M0, EXEC]; 694 let Defs = [M0]; 695} 696 697def V_INDIRECT_REG_WRITE_GPR_IDX_B32_V1 : V_INDIRECT_REG_WRITE_GPR_IDX_pseudo<VGPR_32>; 698def V_INDIRECT_REG_WRITE_GPR_IDX_B32_V2 : V_INDIRECT_REG_WRITE_GPR_IDX_pseudo<VReg_64>; 699def V_INDIRECT_REG_WRITE_GPR_IDX_B32_V3 : V_INDIRECT_REG_WRITE_GPR_IDX_pseudo<VReg_96>; 700def V_INDIRECT_REG_WRITE_GPR_IDX_B32_V4 : V_INDIRECT_REG_WRITE_GPR_IDX_pseudo<VReg_128>; 701def V_INDIRECT_REG_WRITE_GPR_IDX_B32_V5 : V_INDIRECT_REG_WRITE_GPR_IDX_pseudo<VReg_160>; 702def V_INDIRECT_REG_WRITE_GPR_IDX_B32_V8 : V_INDIRECT_REG_WRITE_GPR_IDX_pseudo<VReg_256>; 703def V_INDIRECT_REG_WRITE_GPR_IDX_B32_V16 : V_INDIRECT_REG_WRITE_GPR_IDX_pseudo<VReg_512>; 704def V_INDIRECT_REG_WRITE_GPR_IDX_B32_V32 : V_INDIRECT_REG_WRITE_GPR_IDX_pseudo<VReg_1024>; 705 706class V_INDIRECT_REG_READ_GPR_IDX_pseudo<RegisterClass rc> : PseudoInstSI < 707 (outs VGPR_32:$vdst), (ins rc:$vsrc, SSrc_b32:$idx, i32imm:$subreg)> { 708 let VALU = 1; 709 let Uses = [M0, EXEC]; 710 let Defs = [M0]; 711} 712 713def V_INDIRECT_REG_READ_GPR_IDX_B32_V1 : V_INDIRECT_REG_READ_GPR_IDX_pseudo<VGPR_32>; 714def V_INDIRECT_REG_READ_GPR_IDX_B32_V2 : V_INDIRECT_REG_READ_GPR_IDX_pseudo<VReg_64>; 715def V_INDIRECT_REG_READ_GPR_IDX_B32_V3 : V_INDIRECT_REG_READ_GPR_IDX_pseudo<VReg_96>; 716def V_INDIRECT_REG_READ_GPR_IDX_B32_V4 : V_INDIRECT_REG_READ_GPR_IDX_pseudo<VReg_128>; 717def V_INDIRECT_REG_READ_GPR_IDX_B32_V5 : V_INDIRECT_REG_READ_GPR_IDX_pseudo<VReg_160>; 718def V_INDIRECT_REG_READ_GPR_IDX_B32_V8 : V_INDIRECT_REG_READ_GPR_IDX_pseudo<VReg_256>; 719def V_INDIRECT_REG_READ_GPR_IDX_B32_V16 : V_INDIRECT_REG_READ_GPR_IDX_pseudo<VReg_512>; 720def V_INDIRECT_REG_READ_GPR_IDX_B32_V32 : V_INDIRECT_REG_READ_GPR_IDX_pseudo<VReg_1024>; 721 722multiclass SI_SPILL_SGPR <RegisterClass sgpr_class> { 723 let UseNamedOperandTable = 1, SGPRSpill = 1, Uses = [EXEC] in { 724 def _SAVE : PseudoInstSI < 725 (outs), 726 (ins sgpr_class:$data, i32imm:$addr)> { 727 let mayStore = 1; 728 let mayLoad = 0; 729 } 730 731 def _RESTORE : PseudoInstSI < 732 (outs sgpr_class:$data), 733 (ins i32imm:$addr)> { 734 let mayStore = 0; 735 let mayLoad = 1; 736 } 737 } // End UseNamedOperandTable = 1 738} 739 740// You cannot use M0 as the output of v_readlane_b32 instructions or 741// use it in the sdata operand of SMEM instructions. We still need to 742// be able to spill the physical register m0, so allow it for 743// SI_SPILL_32_* instructions. 744defm SI_SPILL_S32 : SI_SPILL_SGPR <SReg_32>; 745defm SI_SPILL_S64 : SI_SPILL_SGPR <SReg_64>; 746defm SI_SPILL_S96 : SI_SPILL_SGPR <SReg_96>; 747defm SI_SPILL_S128 : SI_SPILL_SGPR <SReg_128>; 748defm SI_SPILL_S160 : SI_SPILL_SGPR <SReg_160>; 749defm SI_SPILL_S192 : SI_SPILL_SGPR <SReg_192>; 750defm SI_SPILL_S224 : SI_SPILL_SGPR <SReg_224>; 751defm SI_SPILL_S256 : SI_SPILL_SGPR <SReg_256>; 752defm SI_SPILL_S512 : SI_SPILL_SGPR <SReg_512>; 753defm SI_SPILL_S1024 : SI_SPILL_SGPR <SReg_1024>; 754 755// VGPR or AGPR spill instructions. In case of AGPR spilling a temp register 756// needs to be used and an extra instruction to move between VGPR and AGPR. 757// UsesTmp adds to the total size of an expanded spill in this case. 758multiclass SI_SPILL_VGPR <RegisterClass vgpr_class, bit UsesTmp = 0> { 759 let UseNamedOperandTable = 1, VGPRSpill = 1, 760 SchedRW = [WriteVMEM] in { 761 def _SAVE : VPseudoInstSI < 762 (outs), 763 (ins vgpr_class:$vdata, i32imm:$vaddr, 764 SReg_32:$soffset, i32imm:$offset)> { 765 let mayStore = 1; 766 let mayLoad = 0; 767 // (2 * 4) + (8 * num_subregs) bytes maximum 768 int MaxSize = !add(!shl(!srl(vgpr_class.Size, 5), !add(UsesTmp, 3)), 8); 769 // Size field is unsigned char and cannot fit more. 770 let Size = !if(!le(MaxSize, 256), MaxSize, 252); 771 } 772 773 def _RESTORE : VPseudoInstSI < 774 (outs vgpr_class:$vdata), 775 (ins i32imm:$vaddr, 776 SReg_32:$soffset, i32imm:$offset)> { 777 let mayStore = 0; 778 let mayLoad = 1; 779 780 // (2 * 4) + (8 * num_subregs) bytes maximum 781 int MaxSize = !add(!shl(!srl(vgpr_class.Size, 5), !add(UsesTmp, 3)), 8); 782 // Size field is unsigned char and cannot fit more. 783 let Size = !if(!le(MaxSize, 256), MaxSize, 252); 784 } 785 } // End UseNamedOperandTable = 1, VGPRSpill = 1, SchedRW = [WriteVMEM] 786} 787 788defm SI_SPILL_V32 : SI_SPILL_VGPR <VGPR_32>; 789defm SI_SPILL_V64 : SI_SPILL_VGPR <VReg_64>; 790defm SI_SPILL_V96 : SI_SPILL_VGPR <VReg_96>; 791defm SI_SPILL_V128 : SI_SPILL_VGPR <VReg_128>; 792defm SI_SPILL_V160 : SI_SPILL_VGPR <VReg_160>; 793defm SI_SPILL_V192 : SI_SPILL_VGPR <VReg_192>; 794defm SI_SPILL_V224 : SI_SPILL_VGPR <VReg_224>; 795defm SI_SPILL_V256 : SI_SPILL_VGPR <VReg_256>; 796defm SI_SPILL_V512 : SI_SPILL_VGPR <VReg_512>; 797defm SI_SPILL_V1024 : SI_SPILL_VGPR <VReg_1024>; 798 799defm SI_SPILL_A32 : SI_SPILL_VGPR <AGPR_32, 1>; 800defm SI_SPILL_A64 : SI_SPILL_VGPR <AReg_64, 1>; 801defm SI_SPILL_A96 : SI_SPILL_VGPR <AReg_96, 1>; 802defm SI_SPILL_A128 : SI_SPILL_VGPR <AReg_128, 1>; 803defm SI_SPILL_A160 : SI_SPILL_VGPR <AReg_160, 1>; 804defm SI_SPILL_A192 : SI_SPILL_VGPR <AReg_192, 1>; 805defm SI_SPILL_A224 : SI_SPILL_VGPR <AReg_224, 1>; 806defm SI_SPILL_A256 : SI_SPILL_VGPR <AReg_256, 1>; 807defm SI_SPILL_A512 : SI_SPILL_VGPR <AReg_512, 1>; 808defm SI_SPILL_A1024 : SI_SPILL_VGPR <AReg_1024, 1>; 809 810defm SI_SPILL_AV32 : SI_SPILL_VGPR <AV_32, 1>; 811defm SI_SPILL_AV64 : SI_SPILL_VGPR <AV_64, 1>; 812defm SI_SPILL_AV96 : SI_SPILL_VGPR <AV_96, 1>; 813defm SI_SPILL_AV128 : SI_SPILL_VGPR <AV_128, 1>; 814defm SI_SPILL_AV160 : SI_SPILL_VGPR <AV_160, 1>; 815defm SI_SPILL_AV192 : SI_SPILL_VGPR <AV_192, 1>; 816defm SI_SPILL_AV224 : SI_SPILL_VGPR <AV_224, 1>; 817defm SI_SPILL_AV256 : SI_SPILL_VGPR <AV_256, 1>; 818defm SI_SPILL_AV512 : SI_SPILL_VGPR <AV_512, 1>; 819defm SI_SPILL_AV1024 : SI_SPILL_VGPR <AV_1024, 1>; 820 821def SI_PC_ADD_REL_OFFSET : SPseudoInstSI < 822 (outs SReg_64:$dst), 823 (ins si_ga:$ptr_lo, si_ga:$ptr_hi), 824 [(set SReg_64:$dst, 825 (i64 (SIpc_add_rel_offset tglobaladdr:$ptr_lo, tglobaladdr:$ptr_hi)))]> { 826 let Defs = [SCC]; 827} 828 829def : GCNPat < 830 (SIpc_add_rel_offset tglobaladdr:$ptr_lo, 0), 831 (SI_PC_ADD_REL_OFFSET $ptr_lo, (i32 0)) 832>; 833 834def : GCNPat< 835 (AMDGPUtrap timm:$trapid), 836 (S_TRAP $trapid) 837>; 838 839def : GCNPat< 840 (AMDGPUelse i1:$src, bb:$target), 841 (SI_ELSE $src, $target) 842>; 843 844def : Pat < 845 (int_amdgcn_kill i1:$src), 846 (SI_KILL_I1_PSEUDO SCSrc_i1:$src, 0) 847>; 848 849def : Pat < 850 (int_amdgcn_kill (i1 (not i1:$src))), 851 (SI_KILL_I1_PSEUDO SCSrc_i1:$src, -1) 852>; 853 854def : Pat < 855 (int_amdgcn_kill (i1 (setcc f32:$src, InlineImmFP32:$imm, cond:$cond))), 856 (SI_KILL_F32_COND_IMM_PSEUDO VSrc_b32:$src, (bitcast_fpimm_to_i32 $imm), (cond_as_i32imm $cond)) 857>; 858 859def : Pat < 860 (int_amdgcn_wqm_demote i1:$src), 861 (SI_DEMOTE_I1 SCSrc_i1:$src, 0) 862>; 863 864def : Pat < 865 (int_amdgcn_wqm_demote (i1 (not i1:$src))), 866 (SI_DEMOTE_I1 SCSrc_i1:$src, -1) 867>; 868 869 // TODO: we could add more variants for other types of conditionals 870 871def : Pat < 872 (i64 (int_amdgcn_icmp i1:$src, (i1 0), (i32 33))), 873 (COPY $src) // Return the SGPRs representing i1 src 874>; 875 876def : Pat < 877 (i32 (int_amdgcn_icmp i1:$src, (i1 0), (i32 33))), 878 (COPY $src) // Return the SGPRs representing i1 src 879>; 880 881//===----------------------------------------------------------------------===// 882// VOP1 Patterns 883//===----------------------------------------------------------------------===// 884 885let OtherPredicates = [UnsafeFPMath] in { 886 887// Convert (x - floor(x)) to fract(x) 888def : GCNPat < 889 (f32 (fsub (f32 (VOP3Mods f32:$x, i32:$mods)), 890 (f32 (ffloor (f32 (VOP3Mods f32:$x, i32:$mods)))))), 891 (V_FRACT_F32_e64 $mods, $x) 892>; 893 894// Convert (x + (-floor(x))) to fract(x) 895def : GCNPat < 896 (f64 (fadd (f64 (VOP3Mods f64:$x, i32:$mods)), 897 (f64 (fneg (f64 (ffloor (f64 (VOP3Mods f64:$x, i32:$mods)))))))), 898 (V_FRACT_F64_e64 $mods, $x) 899>; 900 901} // End OtherPredicates = [UnsafeFPMath] 902 903 904// f16_to_fp patterns 905def : GCNPat < 906 (f32 (f16_to_fp i32:$src0)), 907 (V_CVT_F32_F16_e64 SRCMODS.NONE, $src0) 908>; 909 910def : GCNPat < 911 (f32 (f16_to_fp (and_oneuse i32:$src0, 0x7fff))), 912 (V_CVT_F32_F16_e64 SRCMODS.ABS, $src0) 913>; 914 915def : GCNPat < 916 (f32 (f16_to_fp (i32 (srl_oneuse (and_oneuse i32:$src0, 0x7fff0000), (i32 16))))), 917 (V_CVT_F32_F16_e64 SRCMODS.ABS, (i32 (V_LSHRREV_B32_e64 (i32 16), i32:$src0))) 918>; 919 920def : GCNPat < 921 (f32 (f16_to_fp (or_oneuse i32:$src0, 0x8000))), 922 (V_CVT_F32_F16_e64 SRCMODS.NEG_ABS, $src0) 923>; 924 925def : GCNPat < 926 (f32 (f16_to_fp (xor_oneuse i32:$src0, 0x8000))), 927 (V_CVT_F32_F16_e64 SRCMODS.NEG, $src0) 928>; 929 930def : GCNPat < 931 (f64 (fpextend f16:$src)), 932 (V_CVT_F64_F32_e32 (V_CVT_F32_F16_e32 $src)) 933>; 934 935// fp_to_fp16 patterns 936def : GCNPat < 937 (i32 (AMDGPUfp_to_f16 (f32 (VOP3Mods f32:$src0, i32:$src0_modifiers)))), 938 (V_CVT_F16_F32_e64 $src0_modifiers, f32:$src0) 939>; 940 941def : GCNPat < 942 (i32 (fp_to_sint f16:$src)), 943 (V_CVT_I32_F32_e32 (V_CVT_F32_F16_e32 VSrc_b32:$src)) 944>; 945 946def : GCNPat < 947 (i32 (fp_to_uint f16:$src)), 948 (V_CVT_U32_F32_e32 (V_CVT_F32_F16_e32 VSrc_b32:$src)) 949>; 950 951def : GCNPat < 952 (f16 (sint_to_fp i32:$src)), 953 (V_CVT_F16_F32_e32 (V_CVT_F32_I32_e32 VSrc_b32:$src)) 954>; 955 956def : GCNPat < 957 (f16 (uint_to_fp i32:$src)), 958 (V_CVT_F16_F32_e32 (V_CVT_F32_U32_e32 VSrc_b32:$src)) 959>; 960 961//===----------------------------------------------------------------------===// 962// VOP2 Patterns 963//===----------------------------------------------------------------------===// 964 965// NoMods pattern used for mac. If there are any source modifiers then it's 966// better to select mad instead of mac. 967class FMADPat <ValueType vt, Instruction inst, SDPatternOperator node> 968 : GCNPat <(vt (node (vt (VOP3NoMods vt:$src0)), 969 (vt (VOP3NoMods vt:$src1)), 970 (vt (VOP3NoMods vt:$src2)))), 971 (inst SRCMODS.NONE, $src0, SRCMODS.NONE, $src1, 972 SRCMODS.NONE, $src2, DSTCLAMP.NONE, DSTOMOD.NONE) 973>; 974 975// Prefer mac form when there are no modifiers. 976let AddedComplexity = 9 in { 977let OtherPredicates = [HasMadMacF32Insts] in { 978def : FMADPat <f32, V_MAC_F32_e64, fmad>; 979def : FMADPat <f32, V_MAC_F32_e64, AMDGPUfmad_ftz>; 980} // OtherPredicates = [HasMadMacF32Insts] 981 982// Don't allow source modifiers. If there are any source modifiers then it's 983// better to select mad instead of mac. 984let SubtargetPredicate = isGFX6GFX7GFX10, 985 OtherPredicates = [HasMadMacF32Insts, NoFP32Denormals] in 986def : GCNPat < 987 (f32 (fadd (AMDGPUfmul_legacy (VOP3NoMods f32:$src0), 988 (VOP3NoMods f32:$src1)), 989 (VOP3NoMods f32:$src2))), 990 (V_MAC_LEGACY_F32_e64 SRCMODS.NONE, $src0, SRCMODS.NONE, $src1, 991 SRCMODS.NONE, $src2, DSTCLAMP.NONE, DSTOMOD.NONE) 992>; 993 994// Don't allow source modifiers. If there are any source modifiers then it's 995// better to select fma instead of fmac. 996let SubtargetPredicate = HasFmaLegacy32 in 997def : GCNPat < 998 (f32 (int_amdgcn_fma_legacy (VOP3NoMods f32:$src0), 999 (VOP3NoMods f32:$src1), 1000 (VOP3NoMods f32:$src2))), 1001 (V_FMAC_LEGACY_F32_e64 SRCMODS.NONE, $src0, SRCMODS.NONE, $src1, 1002 SRCMODS.NONE, $src2, DSTCLAMP.NONE, DSTOMOD.NONE) 1003>; 1004 1005let SubtargetPredicate = Has16BitInsts in { 1006def : FMADPat <f16, V_MAC_F16_e64, fmad>; 1007def : FMADPat <f16, V_MAC_F16_e64, AMDGPUfmad_ftz>; 1008} // SubtargetPredicate = Has16BitInsts 1009} // AddedComplexity = 9 1010 1011class FMADModsPat<ValueType Ty, Instruction inst, SDPatternOperator mad_opr> 1012 : GCNPat< 1013 (Ty (mad_opr (Ty (VOP3Mods Ty:$src0, i32:$src0_mod)), 1014 (Ty (VOP3Mods Ty:$src1, i32:$src1_mod)), 1015 (Ty (VOP3Mods Ty:$src2, i32:$src2_mod)))), 1016 (inst $src0_mod, $src0, $src1_mod, $src1, 1017 $src2_mod, $src2, DSTCLAMP.NONE, DSTOMOD.NONE) 1018>; 1019 1020let OtherPredicates = [HasMadMacF32Insts] in 1021def : FMADModsPat<f32, V_MAD_F32_e64, AMDGPUfmad_ftz>; 1022 1023let OtherPredicates = [HasMadMacF32Insts, NoFP32Denormals] in 1024def : GCNPat < 1025 (f32 (fadd (AMDGPUfmul_legacy (VOP3Mods f32:$src0, i32:$src0_mod), 1026 (VOP3Mods f32:$src1, i32:$src1_mod)), 1027 (VOP3Mods f32:$src2, i32:$src2_mod))), 1028 (V_MAD_LEGACY_F32_e64 $src0_mod, $src0, $src1_mod, $src1, 1029 $src2_mod, $src2, DSTCLAMP.NONE, DSTOMOD.NONE) 1030>; 1031 1032let SubtargetPredicate = Has16BitInsts in 1033def : FMADModsPat<f16, V_MAD_F16_e64, AMDGPUfmad_ftz>; 1034 1035class VOPSelectModsPat <ValueType vt> : GCNPat < 1036 (vt (select i1:$src0, (VOP3Mods vt:$src1, i32:$src1_mods), 1037 (VOP3Mods vt:$src2, i32:$src2_mods))), 1038 (V_CNDMASK_B32_e64 FP32InputMods:$src2_mods, VSrc_b32:$src2, 1039 FP32InputMods:$src1_mods, VSrc_b32:$src1, SSrc_i1:$src0) 1040>; 1041 1042class VOPSelectPat <ValueType vt> : GCNPat < 1043 (vt (select i1:$src0, vt:$src1, vt:$src2)), 1044 (V_CNDMASK_B32_e64 0, VSrc_b32:$src2, 0, VSrc_b32:$src1, SSrc_i1:$src0) 1045>; 1046 1047def : VOPSelectModsPat <i32>; 1048def : VOPSelectModsPat <f32>; 1049def : VOPSelectPat <f16>; 1050def : VOPSelectPat <i16>; 1051 1052let AddedComplexity = 1 in { 1053def : GCNPat < 1054 (i32 (add (i32 (getDivergentFrag<ctpop>.ret i32:$popcnt)), i32:$val)), 1055 (V_BCNT_U32_B32_e64 $popcnt, $val) 1056>; 1057} 1058 1059def : GCNPat < 1060 (i32 (DivergentUnaryFrag<ctpop> i32:$popcnt)), 1061 (V_BCNT_U32_B32_e64 VSrc_b32:$popcnt, (i32 0)) 1062>; 1063 1064def : GCNPat < 1065 (i16 (add (i16 (trunc (i32 (getDivergentFrag<ctpop>.ret i32:$popcnt)))), i16:$val)), 1066 (V_BCNT_U32_B32_e64 $popcnt, $val) 1067>; 1068 1069def : GCNPat < 1070 (i64 (DivergentUnaryFrag<ctpop> i64:$src)), 1071 (REG_SEQUENCE VReg_64, 1072 (V_BCNT_U32_B32_e64 (i32 (EXTRACT_SUBREG i64:$src, sub1)), 1073 (i32 (V_BCNT_U32_B32_e64 (i32 (EXTRACT_SUBREG i64:$src, sub0)), (i32 0)))), sub0, 1074 (i32 (V_MOV_B32_e32 (i32 0))), sub1) 1075>; 1076 1077/********** ============================================ **********/ 1078/********** Extraction, Insertion, Building and Casting **********/ 1079/********** ============================================ **********/ 1080 1081// Special case for 2 element vectors. REQ_SEQUENCE produces better code 1082// than an INSERT_SUBREG. 1083multiclass Insert_Element_V2<RegisterClass RC, ValueType elem_type, ValueType vec_type> { 1084 def : GCNPat < 1085 (insertelt vec_type:$vec, elem_type:$elem, 0), 1086 (REG_SEQUENCE RC, $elem, sub0, (elem_type (EXTRACT_SUBREG $vec, sub1)), sub1) 1087 >; 1088 1089 def : GCNPat < 1090 (insertelt vec_type:$vec, elem_type:$elem, 1), 1091 (REG_SEQUENCE RC, (elem_type (EXTRACT_SUBREG $vec, sub0)), sub0, $elem, sub1) 1092 >; 1093} 1094 1095foreach Index = 0-1 in { 1096 def Extract_Element_v2i32_#Index : Extract_Element < 1097 i32, v2i32, Index, !cast<SubRegIndex>(sub#Index) 1098 >; 1099 1100 def Extract_Element_v2f32_#Index : Extract_Element < 1101 f32, v2f32, Index, !cast<SubRegIndex>(sub#Index) 1102 >; 1103} 1104 1105defm : Insert_Element_V2 <SReg_64, i32, v2i32>; 1106defm : Insert_Element_V2 <SReg_64, f32, v2f32>; 1107 1108foreach Index = 0-2 in { 1109 def Extract_Element_v3i32_#Index : Extract_Element < 1110 i32, v3i32, Index, !cast<SubRegIndex>(sub#Index) 1111 >; 1112 def Insert_Element_v3i32_#Index : Insert_Element < 1113 i32, v3i32, Index, !cast<SubRegIndex>(sub#Index) 1114 >; 1115 1116 def Extract_Element_v3f32_#Index : Extract_Element < 1117 f32, v3f32, Index, !cast<SubRegIndex>(sub#Index) 1118 >; 1119 def Insert_Element_v3f32_#Index : Insert_Element < 1120 f32, v3f32, Index, !cast<SubRegIndex>(sub#Index) 1121 >; 1122} 1123 1124foreach Index = 0-3 in { 1125 def Extract_Element_v4i32_#Index : Extract_Element < 1126 i32, v4i32, Index, !cast<SubRegIndex>(sub#Index) 1127 >; 1128 def Insert_Element_v4i32_#Index : Insert_Element < 1129 i32, v4i32, Index, !cast<SubRegIndex>(sub#Index) 1130 >; 1131 1132 def Extract_Element_v4f32_#Index : Extract_Element < 1133 f32, v4f32, Index, !cast<SubRegIndex>(sub#Index) 1134 >; 1135 def Insert_Element_v4f32_#Index : Insert_Element < 1136 f32, v4f32, Index, !cast<SubRegIndex>(sub#Index) 1137 >; 1138} 1139 1140foreach Index = 0-4 in { 1141 def Extract_Element_v5i32_#Index : Extract_Element < 1142 i32, v5i32, Index, !cast<SubRegIndex>(sub#Index) 1143 >; 1144 def Insert_Element_v5i32_#Index : Insert_Element < 1145 i32, v5i32, Index, !cast<SubRegIndex>(sub#Index) 1146 >; 1147 1148 def Extract_Element_v5f32_#Index : Extract_Element < 1149 f32, v5f32, Index, !cast<SubRegIndex>(sub#Index) 1150 >; 1151 def Insert_Element_v5f32_#Index : Insert_Element < 1152 f32, v5f32, Index, !cast<SubRegIndex>(sub#Index) 1153 >; 1154} 1155 1156foreach Index = 0-5 in { 1157 def Extract_Element_v6i32_#Index : Extract_Element < 1158 i32, v6i32, Index, !cast<SubRegIndex>(sub#Index) 1159 >; 1160 def Insert_Element_v6i32_#Index : Insert_Element < 1161 i32, v6i32, Index, !cast<SubRegIndex>(sub#Index) 1162 >; 1163 1164 def Extract_Element_v6f32_#Index : Extract_Element < 1165 f32, v6f32, Index, !cast<SubRegIndex>(sub#Index) 1166 >; 1167 def Insert_Element_v6f32_#Index : Insert_Element < 1168 f32, v6f32, Index, !cast<SubRegIndex>(sub#Index) 1169 >; 1170} 1171 1172foreach Index = 0-6 in { 1173 def Extract_Element_v7i32_#Index : Extract_Element < 1174 i32, v7i32, Index, !cast<SubRegIndex>(sub#Index) 1175 >; 1176 def Insert_Element_v7i32_#Index : Insert_Element < 1177 i32, v7i32, Index, !cast<SubRegIndex>(sub#Index) 1178 >; 1179 1180 def Extract_Element_v7f32_#Index : Extract_Element < 1181 f32, v7f32, Index, !cast<SubRegIndex>(sub#Index) 1182 >; 1183 def Insert_Element_v7f32_#Index : Insert_Element < 1184 f32, v7f32, Index, !cast<SubRegIndex>(sub#Index) 1185 >; 1186} 1187 1188foreach Index = 0-7 in { 1189 def Extract_Element_v8i32_#Index : Extract_Element < 1190 i32, v8i32, Index, !cast<SubRegIndex>(sub#Index) 1191 >; 1192 def Insert_Element_v8i32_#Index : Insert_Element < 1193 i32, v8i32, Index, !cast<SubRegIndex>(sub#Index) 1194 >; 1195 1196 def Extract_Element_v8f32_#Index : Extract_Element < 1197 f32, v8f32, Index, !cast<SubRegIndex>(sub#Index) 1198 >; 1199 def Insert_Element_v8f32_#Index : Insert_Element < 1200 f32, v8f32, Index, !cast<SubRegIndex>(sub#Index) 1201 >; 1202} 1203 1204foreach Index = 0-15 in { 1205 def Extract_Element_v16i32_#Index : Extract_Element < 1206 i32, v16i32, Index, !cast<SubRegIndex>(sub#Index) 1207 >; 1208 def Insert_Element_v16i32_#Index : Insert_Element < 1209 i32, v16i32, Index, !cast<SubRegIndex>(sub#Index) 1210 >; 1211 1212 def Extract_Element_v16f32_#Index : Extract_Element < 1213 f32, v16f32, Index, !cast<SubRegIndex>(sub#Index) 1214 >; 1215 def Insert_Element_v16f32_#Index : Insert_Element < 1216 f32, v16f32, Index, !cast<SubRegIndex>(sub#Index) 1217 >; 1218} 1219 1220 1221def : Pat < 1222 (extract_subvector v4i16:$vec, (i32 0)), 1223 (v2i16 (EXTRACT_SUBREG v4i16:$vec, sub0)) 1224>; 1225 1226def : Pat < 1227 (extract_subvector v4i16:$vec, (i32 2)), 1228 (v2i16 (EXTRACT_SUBREG v4i16:$vec, sub1)) 1229>; 1230 1231def : Pat < 1232 (extract_subvector v4f16:$vec, (i32 0)), 1233 (v2f16 (EXTRACT_SUBREG v4f16:$vec, sub0)) 1234>; 1235 1236def : Pat < 1237 (extract_subvector v4f16:$vec, (i32 2)), 1238 (v2f16 (EXTRACT_SUBREG v4f16:$vec, sub1)) 1239>; 1240 1241def : Pat < 1242 (extract_subvector v8i16:$vec, (i32 0)), 1243 (v4i16 (EXTRACT_SUBREG v8i16:$vec, sub0_sub1)) 1244>; 1245 1246def : Pat < 1247 (extract_subvector v8i16:$vec, (i32 4)), 1248 (v4i16 (EXTRACT_SUBREG v8i16:$vec, sub2_sub3)) 1249>; 1250 1251def : Pat < 1252 (extract_subvector v8f16:$vec, (i32 0)), 1253 (v4f16 (EXTRACT_SUBREG v8f16:$vec, sub0_sub1)) 1254>; 1255 1256def : Pat < 1257 (extract_subvector v8f16:$vec, (i32 4)), 1258 (v4f16 (EXTRACT_SUBREG v8f16:$vec, sub2_sub3)) 1259>; 1260 1261def : Pat < 1262 (extract_subvector v16i16:$vec, (i32 0)), 1263 (v8i16 (EXTRACT_SUBREG v16i16:$vec, sub0_sub1_sub2_sub3)) 1264>; 1265 1266def : Pat < 1267 (extract_subvector v16i16:$vec, (i32 8)), 1268 (v8i16 (EXTRACT_SUBREG v16i16:$vec, sub4_sub5_sub6_sub7)) 1269>; 1270 1271def : Pat < 1272 (extract_subvector v16f16:$vec, (i32 0)), 1273 (v8f16 (EXTRACT_SUBREG v16f16:$vec, sub0_sub1_sub2_sub3)) 1274>; 1275 1276def : Pat < 1277 (extract_subvector v16f16:$vec, (i32 8)), 1278 (v8f16 (EXTRACT_SUBREG v16f16:$vec, sub4_sub5_sub6_sub7)) 1279>; 1280 1281foreach Index = 0-31 in { 1282 def Extract_Element_v32i32_#Index : Extract_Element < 1283 i32, v32i32, Index, !cast<SubRegIndex>(sub#Index) 1284 >; 1285 1286 def Insert_Element_v32i32_#Index : Insert_Element < 1287 i32, v32i32, Index, !cast<SubRegIndex>(sub#Index) 1288 >; 1289 1290 def Extract_Element_v32f32_#Index : Extract_Element < 1291 f32, v32f32, Index, !cast<SubRegIndex>(sub#Index) 1292 >; 1293 1294 def Insert_Element_v32f32_#Index : Insert_Element < 1295 f32, v32f32, Index, !cast<SubRegIndex>(sub#Index) 1296 >; 1297} 1298 1299// FIXME: Why do only some of these type combinations for SReg and 1300// VReg? 1301// 16-bit bitcast 1302def : BitConvert <i16, f16, VGPR_32>; 1303def : BitConvert <f16, i16, VGPR_32>; 1304def : BitConvert <i16, f16, SReg_32>; 1305def : BitConvert <f16, i16, SReg_32>; 1306 1307// 32-bit bitcast 1308def : BitConvert <i32, f32, VGPR_32>; 1309def : BitConvert <f32, i32, VGPR_32>; 1310def : BitConvert <i32, f32, SReg_32>; 1311def : BitConvert <f32, i32, SReg_32>; 1312def : BitConvert <v2i16, i32, SReg_32>; 1313def : BitConvert <i32, v2i16, SReg_32>; 1314def : BitConvert <v2f16, i32, SReg_32>; 1315def : BitConvert <i32, v2f16, SReg_32>; 1316def : BitConvert <v2i16, v2f16, SReg_32>; 1317def : BitConvert <v2f16, v2i16, SReg_32>; 1318def : BitConvert <v2f16, f32, SReg_32>; 1319def : BitConvert <f32, v2f16, SReg_32>; 1320def : BitConvert <v2i16, f32, SReg_32>; 1321def : BitConvert <f32, v2i16, SReg_32>; 1322 1323// 64-bit bitcast 1324def : BitConvert <i64, f64, VReg_64>; 1325def : BitConvert <f64, i64, VReg_64>; 1326def : BitConvert <v2i32, v2f32, VReg_64>; 1327def : BitConvert <v2f32, v2i32, VReg_64>; 1328def : BitConvert <i64, v2i32, VReg_64>; 1329def : BitConvert <v2i32, i64, VReg_64>; 1330def : BitConvert <i64, v2f32, VReg_64>; 1331def : BitConvert <v2f32, i64, VReg_64>; 1332def : BitConvert <f64, v2f32, VReg_64>; 1333def : BitConvert <v2f32, f64, VReg_64>; 1334def : BitConvert <f64, v2i32, VReg_64>; 1335def : BitConvert <v2i32, f64, VReg_64>; 1336def : BitConvert <v4i16, v4f16, VReg_64>; 1337def : BitConvert <v4f16, v4i16, VReg_64>; 1338 1339// FIXME: Make SGPR 1340def : BitConvert <v2i32, v4f16, VReg_64>; 1341def : BitConvert <v4f16, v2i32, VReg_64>; 1342def : BitConvert <v2i32, v4f16, VReg_64>; 1343def : BitConvert <v2i32, v4i16, VReg_64>; 1344def : BitConvert <v4i16, v2i32, VReg_64>; 1345def : BitConvert <v2f32, v4f16, VReg_64>; 1346def : BitConvert <v4f16, v2f32, VReg_64>; 1347def : BitConvert <v2f32, v4i16, VReg_64>; 1348def : BitConvert <v4i16, v2f32, VReg_64>; 1349def : BitConvert <v4i16, f64, VReg_64>; 1350def : BitConvert <v4f16, f64, VReg_64>; 1351def : BitConvert <f64, v4i16, VReg_64>; 1352def : BitConvert <f64, v4f16, VReg_64>; 1353def : BitConvert <v4i16, i64, VReg_64>; 1354def : BitConvert <v4f16, i64, VReg_64>; 1355def : BitConvert <i64, v4i16, VReg_64>; 1356def : BitConvert <i64, v4f16, VReg_64>; 1357 1358def : BitConvert <v4i32, v4f32, VReg_128>; 1359def : BitConvert <v4f32, v4i32, VReg_128>; 1360 1361// 96-bit bitcast 1362def : BitConvert <v3i32, v3f32, SGPR_96>; 1363def : BitConvert <v3f32, v3i32, SGPR_96>; 1364 1365// 128-bit bitcast 1366def : BitConvert <v2i64, v4i32, SReg_128>; 1367def : BitConvert <v4i32, v2i64, SReg_128>; 1368def : BitConvert <v2f64, v4f32, VReg_128>; 1369def : BitConvert <v2f64, v4i32, VReg_128>; 1370def : BitConvert <v4f32, v2f64, VReg_128>; 1371def : BitConvert <v4i32, v2f64, VReg_128>; 1372def : BitConvert <v2i64, v2f64, VReg_128>; 1373def : BitConvert <v2f64, v2i64, VReg_128>; 1374def : BitConvert <v4f32, v2i64, VReg_128>; 1375def : BitConvert <v2i64, v4f32, VReg_128>; 1376def : BitConvert <v8i16, v4i32, SReg_128>; 1377def : BitConvert <v4i32, v8i16, SReg_128>; 1378def : BitConvert <v8f16, v4f32, VReg_128>; 1379def : BitConvert <v8f16, v4i32, VReg_128>; 1380def : BitConvert <v4f32, v8f16, VReg_128>; 1381def : BitConvert <v4i32, v8f16, VReg_128>; 1382def : BitConvert <v8i16, v8f16, VReg_128>; 1383def : BitConvert <v8f16, v8i16, VReg_128>; 1384def : BitConvert <v4f32, v8i16, VReg_128>; 1385def : BitConvert <v8i16, v4f32, VReg_128>; 1386def : BitConvert <v8i16, v8f16, SReg_128>; 1387def : BitConvert <v8i16, v2i64, SReg_128>; 1388def : BitConvert <v8i16, v2f64, SReg_128>; 1389def : BitConvert <v8f16, v2i64, SReg_128>; 1390def : BitConvert <v8f16, v2f64, SReg_128>; 1391def : BitConvert <v8f16, v8i16, SReg_128>; 1392def : BitConvert <v2i64, v8i16, SReg_128>; 1393def : BitConvert <v2f64, v8i16, SReg_128>; 1394def : BitConvert <v2i64, v8f16, SReg_128>; 1395def : BitConvert <v2f64, v8f16, SReg_128>; 1396 1397// 160-bit bitcast 1398def : BitConvert <v5i32, v5f32, SReg_160>; 1399def : BitConvert <v5f32, v5i32, SReg_160>; 1400def : BitConvert <v5i32, v5f32, VReg_160>; 1401def : BitConvert <v5f32, v5i32, VReg_160>; 1402 1403// 192-bit bitcast 1404def : BitConvert <v6i32, v6f32, SReg_192>; 1405def : BitConvert <v6f32, v6i32, SReg_192>; 1406def : BitConvert <v6i32, v6f32, VReg_192>; 1407def : BitConvert <v6f32, v6i32, VReg_192>; 1408def : BitConvert <v3i64, v3f64, VReg_192>; 1409def : BitConvert <v3f64, v3i64, VReg_192>; 1410def : BitConvert <v3i64, v6i32, VReg_192>; 1411def : BitConvert <v3i64, v6f32, VReg_192>; 1412def : BitConvert <v3f64, v6i32, VReg_192>; 1413def : BitConvert <v3f64, v6f32, VReg_192>; 1414def : BitConvert <v6i32, v3i64, VReg_192>; 1415def : BitConvert <v6f32, v3i64, VReg_192>; 1416def : BitConvert <v6i32, v3f64, VReg_192>; 1417def : BitConvert <v6f32, v3f64, VReg_192>; 1418 1419// 224-bit bitcast 1420def : BitConvert <v7i32, v7f32, SReg_224>; 1421def : BitConvert <v7f32, v7i32, SReg_224>; 1422def : BitConvert <v7i32, v7f32, VReg_224>; 1423def : BitConvert <v7f32, v7i32, VReg_224>; 1424 1425// 256-bit bitcast 1426def : BitConvert <v8i32, v8f32, SReg_256>; 1427def : BitConvert <v8f32, v8i32, SReg_256>; 1428def : BitConvert <v8i32, v8f32, VReg_256>; 1429def : BitConvert <v8f32, v8i32, VReg_256>; 1430def : BitConvert <v4i64, v4f64, VReg_256>; 1431def : BitConvert <v4f64, v4i64, VReg_256>; 1432def : BitConvert <v4i64, v8i32, VReg_256>; 1433def : BitConvert <v4i64, v8f32, VReg_256>; 1434def : BitConvert <v4f64, v8i32, VReg_256>; 1435def : BitConvert <v4f64, v8f32, VReg_256>; 1436def : BitConvert <v8i32, v4i64, VReg_256>; 1437def : BitConvert <v8f32, v4i64, VReg_256>; 1438def : BitConvert <v8i32, v4f64, VReg_256>; 1439def : BitConvert <v8f32, v4f64, VReg_256>; 1440def : BitConvert <v16i16, v16f16, SReg_256>; 1441def : BitConvert <v16f16, v16i16, SReg_256>; 1442def : BitConvert <v16i16, v16f16, VReg_256>; 1443def : BitConvert <v16f16, v16i16, VReg_256>; 1444def : BitConvert <v16f16, v8i32, VReg_256>; 1445def : BitConvert <v16i16, v8i32, VReg_256>; 1446def : BitConvert <v16f16, v8f32, VReg_256>; 1447def : BitConvert <v16i16, v8f32, VReg_256>; 1448def : BitConvert <v8i32, v16f16, VReg_256>; 1449def : BitConvert <v8i32, v16i16, VReg_256>; 1450def : BitConvert <v8f32, v16f16, VReg_256>; 1451def : BitConvert <v8f32, v16i16, VReg_256>; 1452def : BitConvert <v16f16, v4i64, VReg_256>; 1453def : BitConvert <v16i16, v4i64, VReg_256>; 1454def : BitConvert <v16f16, v4f64, VReg_256>; 1455def : BitConvert <v16i16, v4f64, VReg_256>; 1456def : BitConvert <v4i64, v16f16, VReg_256>; 1457def : BitConvert <v4i64, v16i16, VReg_256>; 1458def : BitConvert <v4f64, v16f16, VReg_256>; 1459def : BitConvert <v4f64, v16i16, VReg_256>; 1460 1461// 512-bit bitcast 1462def : BitConvert <v16i32, v16f32, VReg_512>; 1463def : BitConvert <v16f32, v16i32, VReg_512>; 1464def : BitConvert <v8i64, v8f64, VReg_512>; 1465def : BitConvert <v8f64, v8i64, VReg_512>; 1466def : BitConvert <v8i64, v16i32, VReg_512>; 1467def : BitConvert <v8f64, v16i32, VReg_512>; 1468def : BitConvert <v16i32, v8i64, VReg_512>; 1469def : BitConvert <v16i32, v8f64, VReg_512>; 1470def : BitConvert <v8i64, v16f32, VReg_512>; 1471def : BitConvert <v8f64, v16f32, VReg_512>; 1472def : BitConvert <v16f32, v8i64, VReg_512>; 1473def : BitConvert <v16f32, v8f64, VReg_512>; 1474 1475// 1024-bit bitcast 1476def : BitConvert <v32i32, v32f32, VReg_1024>; 1477def : BitConvert <v32f32, v32i32, VReg_1024>; 1478def : BitConvert <v16i64, v16f64, VReg_1024>; 1479def : BitConvert <v16f64, v16i64, VReg_1024>; 1480def : BitConvert <v16i64, v32i32, VReg_1024>; 1481def : BitConvert <v32i32, v16i64, VReg_1024>; 1482def : BitConvert <v16f64, v32f32, VReg_1024>; 1483def : BitConvert <v32f32, v16f64, VReg_1024>; 1484def : BitConvert <v16i64, v32f32, VReg_1024>; 1485def : BitConvert <v32i32, v16f64, VReg_1024>; 1486def : BitConvert <v16f64, v32i32, VReg_1024>; 1487def : BitConvert <v32f32, v16i64, VReg_1024>; 1488 1489 1490/********** =================== **********/ 1491/********** Src & Dst modifiers **********/ 1492/********** =================== **********/ 1493 1494 1495// If denormals are not enabled, it only impacts the compare of the 1496// inputs. The output result is not flushed. 1497class ClampPat<Instruction inst, ValueType vt> : GCNPat < 1498 (vt (AMDGPUclamp (VOP3Mods vt:$src0, i32:$src0_modifiers))), 1499 (inst i32:$src0_modifiers, vt:$src0, 1500 i32:$src0_modifiers, vt:$src0, DSTCLAMP.ENABLE, DSTOMOD.NONE) 1501>; 1502 1503def : ClampPat<V_MAX_F32_e64, f32>; 1504def : ClampPat<V_MAX_F64_e64, f64>; 1505def : ClampPat<V_MAX_F16_e64, f16>; 1506 1507let SubtargetPredicate = HasVOP3PInsts in { 1508def : GCNPat < 1509 (v2f16 (AMDGPUclamp (VOP3PMods v2f16:$src0, i32:$src0_modifiers))), 1510 (V_PK_MAX_F16 $src0_modifiers, $src0, 1511 $src0_modifiers, $src0, DSTCLAMP.ENABLE) 1512>; 1513} 1514 1515 1516/********** ================================ **********/ 1517/********** Floating point absolute/negative **********/ 1518/********** ================================ **********/ 1519 1520def : GCNPat < 1521 (UniformUnaryFrag<fneg> (fabs (f32 SReg_32:$src))), 1522 (S_OR_B32 SReg_32:$src, (S_MOV_B32 (i32 0x80000000))) // Set sign bit 1523>; 1524 1525def : GCNPat < 1526 (UniformUnaryFrag<fabs> (f32 SReg_32:$src)), 1527 (S_AND_B32 SReg_32:$src, (S_MOV_B32 (i32 0x7fffffff))) 1528>; 1529 1530def : GCNPat < 1531 (UniformUnaryFrag<fneg> (f32 SReg_32:$src)), 1532 (S_XOR_B32 SReg_32:$src, (S_MOV_B32 (i32 0x80000000))) 1533>; 1534 1535def : GCNPat < 1536 (UniformUnaryFrag<fneg> (f16 SReg_32:$src)), 1537 (S_XOR_B32 SReg_32:$src, (S_MOV_B32 (i32 0x00008000))) 1538>; 1539 1540def : GCNPat < 1541 (UniformUnaryFrag<fabs> (f16 SReg_32:$src)), 1542 (S_AND_B32 SReg_32:$src, (S_MOV_B32 (i32 0x00007fff))) 1543>; 1544 1545def : GCNPat < 1546 (UniformUnaryFrag<fneg> (fabs (f16 SReg_32:$src))), 1547 (S_OR_B32 SReg_32:$src, (S_MOV_B32 (i32 0x00008000))) // Set sign bit 1548>; 1549 1550def : GCNPat < 1551 (UniformUnaryFrag<fneg> (v2f16 SReg_32:$src)), 1552 (S_XOR_B32 SReg_32:$src, (S_MOV_B32 (i32 0x80008000))) 1553>; 1554 1555def : GCNPat < 1556 (UniformUnaryFrag<fabs> (v2f16 SReg_32:$src)), 1557 (S_AND_B32 SReg_32:$src, (S_MOV_B32 (i32 0x7fff7fff))) 1558>; 1559 1560// This is really (fneg (fabs v2f16:$src)) 1561// 1562// fabs is not reported as free because there is modifier for it in 1563// VOP3P instructions, so it is turned into the bit op. 1564def : GCNPat < 1565 (UniformUnaryFrag<fneg> (v2f16 (bitconvert (and_oneuse (i32 SReg_32:$src), 0x7fff7fff)))), 1566 (S_OR_B32 SReg_32:$src, (S_MOV_B32 (i32 0x80008000))) // Set sign bit 1567>; 1568 1569def : GCNPat < 1570 (UniformUnaryFrag<fneg> (v2f16 (fabs SReg_32:$src))), 1571 (S_OR_B32 SReg_32:$src, (S_MOV_B32 (i32 0x80008000))) // Set sign bit 1572>; 1573 1574 1575// COPY_TO_REGCLASS is needed to avoid using SCC from S_XOR_B32 instead 1576// of the real value. 1577def : GCNPat < 1578 (UniformUnaryFrag<fneg> (v2f32 SReg_64:$src)), 1579 (v2f32 (REG_SEQUENCE SReg_64, 1580 (f32 (COPY_TO_REGCLASS (S_XOR_B32 (i32 (EXTRACT_SUBREG $src, sub0)), 1581 (i32 (S_MOV_B32 (i32 0x80000000)))), 1582 SReg_32)), sub0, 1583 (f32 (COPY_TO_REGCLASS (S_XOR_B32 (i32 (EXTRACT_SUBREG $src, sub1)), 1584 (i32 (S_MOV_B32 (i32 0x80000000)))), 1585 SReg_32)), sub1)) 1586>; 1587 1588def : GCNPat < 1589 (UniformUnaryFrag<fabs> (v2f32 SReg_64:$src)), 1590 (v2f32 (REG_SEQUENCE SReg_64, 1591 (f32 (COPY_TO_REGCLASS (S_AND_B32 (i32 (EXTRACT_SUBREG $src, sub0)), 1592 (i32 (S_MOV_B32 (i32 0x7fffffff)))), 1593 SReg_32)), sub0, 1594 (f32 (COPY_TO_REGCLASS (S_AND_B32 (i32 (EXTRACT_SUBREG $src, sub1)), 1595 (i32 (S_MOV_B32 (i32 0x7fffffff)))), 1596 SReg_32)), sub1)) 1597>; 1598 1599def : GCNPat < 1600 (UniformUnaryFrag<fneg> (fabs (v2f32 SReg_64:$src))), 1601 (v2f32 (REG_SEQUENCE SReg_64, 1602 (f32 (COPY_TO_REGCLASS (S_OR_B32 (i32 (EXTRACT_SUBREG $src, sub0)), 1603 (i32 (S_MOV_B32 (i32 0x80000000)))), 1604 SReg_32)), sub0, 1605 (f32 (COPY_TO_REGCLASS (S_OR_B32 (i32 (EXTRACT_SUBREG $src, sub1)), 1606 (i32 (S_MOV_B32 (i32 0x80000000)))), 1607 SReg_32)), sub1)) 1608>; 1609 1610// FIXME: Use S_BITSET0_B32/B64? 1611def : GCNPat < 1612 (UniformUnaryFrag<fabs> (f64 SReg_64:$src)), 1613 (REG_SEQUENCE SReg_64, 1614 (i32 (EXTRACT_SUBREG SReg_64:$src, sub0)), 1615 sub0, 1616 (i32 (COPY_TO_REGCLASS (S_AND_B32 (i32 (EXTRACT_SUBREG SReg_64:$src, sub1)), 1617 (S_MOV_B32 (i32 0x7fffffff))), SReg_32)), // Set sign bit. 1618 sub1) 1619>; 1620 1621def : GCNPat < 1622 (UniformUnaryFrag<fneg> (f64 SReg_64:$src)), 1623 (REG_SEQUENCE SReg_64, 1624 (i32 (EXTRACT_SUBREG SReg_64:$src, sub0)), 1625 sub0, 1626 (i32 (COPY_TO_REGCLASS (S_XOR_B32 (i32 (EXTRACT_SUBREG SReg_64:$src, sub1)), 1627 (i32 (S_MOV_B32 (i32 0x80000000)))), SReg_32)), 1628 sub1) 1629>; 1630 1631def : GCNPat < 1632 (UniformUnaryFrag<fneg> (fabs (f64 SReg_64:$src))), 1633 (REG_SEQUENCE SReg_64, 1634 (i32 (EXTRACT_SUBREG SReg_64:$src, sub0)), 1635 sub0, 1636 (i32 (COPY_TO_REGCLASS (S_OR_B32 (i32 (EXTRACT_SUBREG SReg_64:$src, sub1)), 1637 (S_MOV_B32 (i32 0x80000000))), SReg_32)),// Set sign bit. 1638 sub1) 1639>; 1640 1641 1642def : GCNPat < 1643 (fneg (fabs (f32 VGPR_32:$src))), 1644 (V_OR_B32_e64 (S_MOV_B32 (i32 0x80000000)), VGPR_32:$src) // Set sign bit 1645>; 1646 1647def : GCNPat < 1648 (fabs (f32 VGPR_32:$src)), 1649 (V_AND_B32_e64 (S_MOV_B32 (i32 0x7fffffff)), VGPR_32:$src) 1650>; 1651 1652def : GCNPat < 1653 (fneg (f32 VGPR_32:$src)), 1654 (V_XOR_B32_e64 (S_MOV_B32 (i32 0x80000000)), VGPR_32:$src) 1655>; 1656 1657def : GCNPat < 1658 (fabs (f16 VGPR_32:$src)), 1659 (V_AND_B32_e64 (S_MOV_B32 (i32 0x00007fff)), VGPR_32:$src) 1660>; 1661 1662def : GCNPat < 1663 (fneg (f16 VGPR_32:$src)), 1664 (V_XOR_B32_e64 (S_MOV_B32 (i32 0x00008000)), VGPR_32:$src) 1665>; 1666 1667def : GCNPat < 1668 (fneg (fabs (f16 VGPR_32:$src))), 1669 (V_OR_B32_e64 (S_MOV_B32 (i32 0x00008000)), VGPR_32:$src) // Set sign bit 1670>; 1671 1672def : GCNPat < 1673 (fneg (v2f16 VGPR_32:$src)), 1674 (V_XOR_B32_e64 (S_MOV_B32 (i32 0x80008000)), VGPR_32:$src) 1675>; 1676 1677def : GCNPat < 1678 (fabs (v2f16 VGPR_32:$src)), 1679 (V_AND_B32_e64 (S_MOV_B32 (i32 0x7fff7fff)), VGPR_32:$src) 1680>; 1681 1682def : GCNPat < 1683 (fneg (v2f16 (fabs VGPR_32:$src))), 1684 (V_OR_B32_e64 (S_MOV_B32 (i32 0x80008000)), VGPR_32:$src) 1685>; 1686 1687def : GCNPat < 1688 (fabs (f64 VReg_64:$src)), 1689 (REG_SEQUENCE VReg_64, 1690 (i32 (EXTRACT_SUBREG VReg_64:$src, sub0)), 1691 sub0, 1692 (V_AND_B32_e64 (i32 (S_MOV_B32 (i32 0x7fffffff))), 1693 (i32 (EXTRACT_SUBREG VReg_64:$src, sub1))), 1694 sub1) 1695>; 1696 1697def : GCNPat < 1698 (fneg (f64 VReg_64:$src)), 1699 (REG_SEQUENCE VReg_64, 1700 (i32 (EXTRACT_SUBREG VReg_64:$src, sub0)), 1701 sub0, 1702 (V_XOR_B32_e64 (i32 (S_MOV_B32 (i32 0x80000000))), 1703 (i32 (EXTRACT_SUBREG VReg_64:$src, sub1))), 1704 sub1) 1705>; 1706 1707def : GCNPat < 1708 (fneg (fabs (f64 VReg_64:$src))), 1709 (REG_SEQUENCE VReg_64, 1710 (i32 (EXTRACT_SUBREG VReg_64:$src, sub0)), 1711 sub0, 1712 (V_OR_B32_e64 (i32 (S_MOV_B32 (i32 0x80000000))), 1713 (i32 (EXTRACT_SUBREG VReg_64:$src, sub1))), 1714 sub1) 1715>; 1716 1717def : GCNPat < 1718 (getDivergentFrag<fneg>.ret (v2f32 VReg_64:$src)), 1719 (V_PK_ADD_F32 11 /* OP_SEL_1 | NEG_LO | HEG_HI */, VReg_64:$src, 1720 11 /* OP_SEL_1 | NEG_LO | HEG_HI */, 0, 1721 0, 0, 0, 0, 0) 1722> { 1723 let SubtargetPredicate = HasPackedFP32Ops; 1724} 1725 1726def : GCNPat < 1727 (fcopysign f16:$src0, f16:$src1), 1728 (V_BFI_B32_e64 (S_MOV_B32 (i32 0x00007fff)), $src0, $src1) 1729>; 1730 1731def : GCNPat < 1732 (fcopysign f32:$src0, f16:$src1), 1733 (V_BFI_B32_e64 (S_MOV_B32 (i32 0x7fffffff)), $src0, 1734 (V_LSHLREV_B32_e64 (i32 16), $src1)) 1735>; 1736 1737def : GCNPat < 1738 (fcopysign f64:$src0, f16:$src1), 1739 (REG_SEQUENCE SReg_64, 1740 (i32 (EXTRACT_SUBREG $src0, sub0)), sub0, 1741 (V_BFI_B32_e64 (S_MOV_B32 (i32 0x7fffffff)), (i32 (EXTRACT_SUBREG $src0, sub1)), 1742 (V_LSHLREV_B32_e64 (i32 16), $src1)), sub1) 1743>; 1744 1745def : GCNPat < 1746 (fcopysign f16:$src0, f32:$src1), 1747 (V_BFI_B32_e64 (S_MOV_B32 (i32 0x00007fff)), $src0, 1748 (V_LSHRREV_B32_e64 (i32 16), $src1)) 1749>; 1750 1751def : GCNPat < 1752 (fcopysign f16:$src0, f64:$src1), 1753 (V_BFI_B32_e64 (S_MOV_B32 (i32 0x00007fff)), $src0, 1754 (V_LSHRREV_B32_e64 (i32 16), (EXTRACT_SUBREG $src1, sub1))) 1755>; 1756 1757/********** ================== **********/ 1758/********** Immediate Patterns **********/ 1759/********** ================== **********/ 1760 1761def : GCNPat < 1762 (VGPRImm<(i32 imm)>:$imm), 1763 (V_MOV_B32_e32 imm:$imm) 1764>; 1765 1766def : GCNPat < 1767 (VGPRImm<(f32 fpimm)>:$imm), 1768 (V_MOV_B32_e32 (f32 (bitcast_fpimm_to_i32 $imm))) 1769>; 1770 1771def : GCNPat < 1772 (i32 imm:$imm), 1773 (S_MOV_B32 imm:$imm) 1774>; 1775 1776def : GCNPat < 1777 (VGPRImm<(SIlds tglobaladdr:$ga)>), 1778 (V_MOV_B32_e32 $ga) 1779>; 1780 1781def : GCNPat < 1782 (SIlds tglobaladdr:$ga), 1783 (S_MOV_B32 $ga) 1784>; 1785 1786// FIXME: Workaround for ordering issue with peephole optimizer where 1787// a register class copy interferes with immediate folding. Should 1788// use s_mov_b32, which can be shrunk to s_movk_i32 1789def : GCNPat < 1790 (VGPRImm<(f16 fpimm)>:$imm), 1791 (V_MOV_B32_e32 (f16 (bitcast_fpimm_to_i32 $imm))) 1792>; 1793 1794def : GCNPat < 1795 (f32 fpimm:$imm), 1796 (S_MOV_B32 (f32 (bitcast_fpimm_to_i32 $imm))) 1797>; 1798 1799def : GCNPat < 1800 (f16 fpimm:$imm), 1801 (S_MOV_B32 (i32 (bitcast_fpimm_to_i32 $imm))) 1802>; 1803 1804def : GCNPat < 1805 (p5 frameindex:$fi), 1806 (V_MOV_B32_e32 (p5 (frameindex_to_targetframeindex $fi))) 1807>; 1808 1809def : GCNPat < 1810 (p5 frameindex:$fi), 1811 (S_MOV_B32 (p5 (frameindex_to_targetframeindex $fi))) 1812>; 1813 1814def : GCNPat < 1815 (i64 InlineImm64:$imm), 1816 (S_MOV_B64 InlineImm64:$imm) 1817>; 1818 1819// XXX - Should this use a s_cmp to set SCC? 1820 1821// Set to sign-extended 64-bit value (true = -1, false = 0) 1822def : GCNPat < 1823 (i1 imm:$imm), 1824 (S_MOV_B64 (i64 (as_i64imm $imm))) 1825> { 1826 let WaveSizePredicate = isWave64; 1827} 1828 1829def : GCNPat < 1830 (i1 imm:$imm), 1831 (S_MOV_B32 (i32 (as_i32imm $imm))) 1832> { 1833 let WaveSizePredicate = isWave32; 1834} 1835 1836def : GCNPat < 1837 (f64 InlineImmFP64:$imm), 1838 (S_MOV_B64 (f64 (bitcast_fpimm_to_i64 InlineImmFP64:$imm))) 1839>; 1840 1841/********** ================== **********/ 1842/********** Intrinsic Patterns **********/ 1843/********** ================== **********/ 1844 1845def : GCNPat < 1846 (f32 (fpow (VOP3Mods f32:$src0, i32:$src0_mods), (VOP3Mods f32:$src1, i32:$src1_mods))), 1847 (V_EXP_F32_e64 SRCMODS.NONE, (V_MUL_LEGACY_F32_e64 $src1_mods, $src1, SRCMODS.NONE, (V_LOG_F32_e64 $src0_mods, $src0), 0, 0)) 1848>; 1849 1850def : GCNPat < 1851 (i32 (sext i1:$src0)), 1852 (V_CNDMASK_B32_e64 /*src0mod*/(i32 0), /*src0*/(i32 0), 1853 /*src1mod*/(i32 0), /*src1*/(i32 -1), $src0) 1854>; 1855 1856class Ext32Pat <SDNode ext> : GCNPat < 1857 (i32 (ext i1:$src0)), 1858 (V_CNDMASK_B32_e64 /*src0mod*/(i32 0), /*src0*/(i32 0), 1859 /*src1mod*/(i32 0), /*src1*/(i32 1), $src0) 1860>; 1861 1862def : Ext32Pat <zext>; 1863def : Ext32Pat <anyext>; 1864 1865// The multiplication scales from [0,1) to the unsigned integer range, 1866// rounding down a bit to avoid unwanted overflow. 1867def : GCNPat < 1868 (AMDGPUurecip i32:$src0), 1869 (V_CVT_U32_F32_e32 1870 (V_MUL_F32_e32 (i32 CONST.FP_4294966784), 1871 (V_RCP_IFLAG_F32_e32 (V_CVT_F32_U32_e32 $src0)))) 1872>; 1873 1874//===----------------------------------------------------------------------===// 1875// VOP3 Patterns 1876//===----------------------------------------------------------------------===// 1877 1878def : IMad24Pat<V_MAD_I32_I24_e64, 1>; 1879def : UMad24Pat<V_MAD_U32_U24_e64, 1>; 1880 1881// BFI patterns 1882 1883def BFIImm32 : PatFrag< 1884 (ops node:$x, node:$y, node:$z), 1885 (i32 (DivergentBinFrag<or> (and node:$y, node:$x), (and node:$z, imm))), 1886 [{ 1887 auto *X = dyn_cast<ConstantSDNode>(N->getOperand(0)->getOperand(1)); 1888 auto *NotX = dyn_cast<ConstantSDNode>(N->getOperand(1)->getOperand(1)); 1889 return X && NotX && 1890 ~(unsigned)X->getZExtValue() == (unsigned)NotX->getZExtValue(); 1891 }] 1892>; 1893 1894// Definition from ISA doc: 1895// (y & x) | (z & ~x) 1896def : AMDGPUPat < 1897 (DivergentBinFrag<or> (and i32:$y, i32:$x), (and i32:$z, (not i32:$x))), 1898 (V_BFI_B32_e64 VSrc_b32:$x, VSrc_b32:$y, VSrc_b32:$z) 1899>; 1900 1901// (y & C) | (z & ~C) 1902def : AMDGPUPat < 1903 (BFIImm32 i32:$x, i32:$y, i32:$z), 1904 (V_BFI_B32_e64 VSrc_b32:$x, VSrc_b32:$y, VSrc_b32:$z) 1905>; 1906 1907// 64-bit version 1908def : AMDGPUPat < 1909 (DivergentBinFrag<or> (and i64:$y, i64:$x), (and i64:$z, (not i64:$x))), 1910 (REG_SEQUENCE VReg_64, 1911 (V_BFI_B32_e64 (i32 (EXTRACT_SUBREG VReg_64:$x, sub0)), 1912 (i32 (EXTRACT_SUBREG VReg_64:$y, sub0)), 1913 (i32 (EXTRACT_SUBREG VReg_64:$z, sub0))), sub0, 1914 (V_BFI_B32_e64 (i32 (EXTRACT_SUBREG VReg_64:$x, sub1)), 1915 (i32 (EXTRACT_SUBREG VReg_64:$y, sub1)), 1916 (i32 (EXTRACT_SUBREG VReg_64:$z, sub1))), sub1) 1917>; 1918 1919// SHA-256 Ch function 1920// z ^ (x & (y ^ z)) 1921def : AMDGPUPat < 1922 (DivergentBinFrag<xor> i32:$z, (and i32:$x, (xor i32:$y, i32:$z))), 1923 (V_BFI_B32_e64 VSrc_b32:$x, VSrc_b32:$y, VSrc_b32:$z) 1924>; 1925 1926// 64-bit version 1927def : AMDGPUPat < 1928 (DivergentBinFrag<xor> i64:$z, (and i64:$x, (xor i64:$y, i64:$z))), 1929 (REG_SEQUENCE VReg_64, 1930 (V_BFI_B32_e64 (i32 (EXTRACT_SUBREG VReg_64:$x, sub0)), 1931 (i32 (EXTRACT_SUBREG VReg_64:$y, sub0)), 1932 (i32 (EXTRACT_SUBREG VReg_64:$z, sub0))), sub0, 1933 (V_BFI_B32_e64 (i32 (EXTRACT_SUBREG VReg_64:$x, sub1)), 1934 (i32 (EXTRACT_SUBREG VReg_64:$y, sub1)), 1935 (i32 (EXTRACT_SUBREG VReg_64:$z, sub1))), sub1) 1936>; 1937 1938def : AMDGPUPat < 1939 (fcopysign f32:$src0, f32:$src1), 1940 (V_BFI_B32_e64 (S_MOV_B32 (i32 0x7fffffff)), $src0, $src1) 1941>; 1942 1943def : AMDGPUPat < 1944 (fcopysign f32:$src0, f64:$src1), 1945 (V_BFI_B32_e64 (S_MOV_B32 (i32 0x7fffffff)), $src0, 1946 (i32 (EXTRACT_SUBREG SReg_64:$src1, sub1))) 1947>; 1948 1949def : AMDGPUPat < 1950 (fcopysign f64:$src0, f64:$src1), 1951 (REG_SEQUENCE SReg_64, 1952 (i32 (EXTRACT_SUBREG $src0, sub0)), sub0, 1953 (V_BFI_B32_e64 (S_MOV_B32 (i32 0x7fffffff)), 1954 (i32 (EXTRACT_SUBREG SReg_64:$src0, sub1)), 1955 (i32 (EXTRACT_SUBREG SReg_64:$src1, sub1))), sub1) 1956>; 1957 1958def : AMDGPUPat < 1959 (fcopysign f64:$src0, f32:$src1), 1960 (REG_SEQUENCE SReg_64, 1961 (i32 (EXTRACT_SUBREG $src0, sub0)), sub0, 1962 (V_BFI_B32_e64 (S_MOV_B32 (i32 0x7fffffff)), 1963 (i32 (EXTRACT_SUBREG SReg_64:$src0, sub1)), 1964 $src1), sub1) 1965>; 1966 1967def : ROTRPattern <V_ALIGNBIT_B32_e64>; 1968 1969def : GCNPat<(i32 (trunc (srl i64:$src0, (and i32:$src1, (i32 31))))), 1970 (V_ALIGNBIT_B32_e64 (i32 (EXTRACT_SUBREG (i64 $src0), sub1)), 1971 (i32 (EXTRACT_SUBREG (i64 $src0), sub0)), $src1)>; 1972 1973def : GCNPat<(i32 (trunc (srl i64:$src0, (i32 ShiftAmt32Imm:$src1)))), 1974 (V_ALIGNBIT_B32_e64 (i32 (EXTRACT_SUBREG (i64 $src0), sub1)), 1975 (i32 (EXTRACT_SUBREG (i64 $src0), sub0)), $src1)>; 1976 1977/********** ====================== **********/ 1978/********** Indirect addressing **********/ 1979/********** ====================== **********/ 1980 1981multiclass SI_INDIRECT_Pattern <ValueType vt, ValueType eltvt, string VecSize> { 1982 // Extract with offset 1983 def : GCNPat< 1984 (eltvt (extractelt vt:$src, (MOVRELOffset i32:$idx, (i32 imm:$offset)))), 1985 (!cast<Instruction>("SI_INDIRECT_SRC_"#VecSize) $src, $idx, imm:$offset) 1986 >; 1987 1988 // Insert with offset 1989 def : GCNPat< 1990 (insertelt vt:$src, eltvt:$val, (MOVRELOffset i32:$idx, (i32 imm:$offset))), 1991 (!cast<Instruction>("SI_INDIRECT_DST_"#VecSize) $src, $idx, imm:$offset, $val) 1992 >; 1993} 1994 1995defm : SI_INDIRECT_Pattern <v2f32, f32, "V2">; 1996defm : SI_INDIRECT_Pattern <v4f32, f32, "V4">; 1997defm : SI_INDIRECT_Pattern <v8f32, f32, "V8">; 1998defm : SI_INDIRECT_Pattern <v16f32, f32, "V16">; 1999defm : SI_INDIRECT_Pattern <v32f32, f32, "V32">; 2000 2001defm : SI_INDIRECT_Pattern <v2i32, i32, "V2">; 2002defm : SI_INDIRECT_Pattern <v4i32, i32, "V4">; 2003defm : SI_INDIRECT_Pattern <v8i32, i32, "V8">; 2004defm : SI_INDIRECT_Pattern <v16i32, i32, "V16">; 2005defm : SI_INDIRECT_Pattern <v32i32, i32, "V32">; 2006 2007//===----------------------------------------------------------------------===// 2008// SAD Patterns 2009//===----------------------------------------------------------------------===// 2010 2011def : GCNPat < 2012 (add (sub_oneuse (umax i32:$src0, i32:$src1), 2013 (umin i32:$src0, i32:$src1)), 2014 i32:$src2), 2015 (V_SAD_U32_e64 $src0, $src1, $src2, (i1 0)) 2016>; 2017 2018def : GCNPat < 2019 (add (select_oneuse (i1 (setugt i32:$src0, i32:$src1)), 2020 (sub i32:$src0, i32:$src1), 2021 (sub i32:$src1, i32:$src0)), 2022 i32:$src2), 2023 (V_SAD_U32_e64 $src0, $src1, $src2, (i1 0)) 2024>; 2025 2026//===----------------------------------------------------------------------===// 2027// Conversion Patterns 2028//===----------------------------------------------------------------------===// 2029def : GCNPat<(i32 (UniformSextInreg<i1> i32:$src)), 2030 (S_BFE_I32 i32:$src, (i32 65536))>; // 0 | 1 << 16 2031 2032// Handle sext_inreg in i64 2033def : GCNPat < 2034 (i64 (UniformSextInreg<i1> i64:$src)), 2035 (S_BFE_I64 i64:$src, (i32 0x10000)) // 0 | 1 << 16 2036>; 2037 2038def : GCNPat < 2039 (i16 (UniformSextInreg<i1> i16:$src)), 2040 (S_BFE_I32 $src, (i32 0x00010000)) // 0 | 1 << 16 2041>; 2042 2043def : GCNPat < 2044 (i16 (UniformSextInreg<i8> i16:$src)), 2045 (S_BFE_I32 $src, (i32 0x80000)) // 0 | 8 << 16 2046>; 2047 2048def : GCNPat < 2049 (i64 (UniformSextInreg<i8> i64:$src)), 2050 (S_BFE_I64 i64:$src, (i32 0x80000)) // 0 | 8 << 16 2051>; 2052 2053def : GCNPat < 2054 (i64 (UniformSextInreg<i16> i64:$src)), 2055 (S_BFE_I64 i64:$src, (i32 0x100000)) // 0 | 16 << 16 2056>; 2057 2058def : GCNPat < 2059 (i64 (UniformSextInreg<i32> i64:$src)), 2060 (S_BFE_I64 i64:$src, (i32 0x200000)) // 0 | 32 << 16 2061>; 2062 2063def : GCNPat< 2064 (i32 (DivergentSextInreg<i1> i32:$src)), 2065 (V_BFE_I32_e64 i32:$src, (i32 0), (i32 1))>; 2066 2067def : GCNPat < 2068 (i16 (DivergentSextInreg<i1> i16:$src)), 2069 (V_BFE_I32_e64 $src, (i32 0), (i32 1)) 2070>; 2071 2072def : GCNPat < 2073 (i16 (DivergentSextInreg<i8> i16:$src)), 2074 (V_BFE_I32_e64 $src, (i32 0), (i32 8)) 2075>; 2076 2077def : GCNPat< 2078 (i32 (DivergentSextInreg<i8> i32:$src)), 2079 (V_BFE_I32_e64 i32:$src, (i32 0), (i32 8)) 2080>; 2081 2082def : GCNPat < 2083 (i32 (DivergentSextInreg<i16> i32:$src)), 2084 (V_BFE_I32_e64 $src, (i32 0), (i32 16)) 2085>; 2086 2087def : GCNPat < 2088 (i64 (DivergentSextInreg<i1> i64:$src)), 2089 (REG_SEQUENCE VReg_64, 2090 (V_BFE_I32_e64 (i32 (EXTRACT_SUBREG i64:$src, sub0)), (i32 0), (i32 1)), sub0, 2091 (V_ASHRREV_I32_e32 (i32 31), (V_BFE_I32_e64 (i32 (EXTRACT_SUBREG i64:$src, sub0)), (i32 0), (i32 1))), sub1) 2092>; 2093 2094def : GCNPat < 2095 (i64 (DivergentSextInreg<i8> i64:$src)), 2096 (REG_SEQUENCE VReg_64, 2097 (V_BFE_I32_e64 (i32 (EXTRACT_SUBREG i64:$src, sub0)), (i32 0), (i32 8)), sub0, 2098 (V_ASHRREV_I32_e32 (i32 31), (V_BFE_I32_e64 (i32 (EXTRACT_SUBREG i64:$src, sub0)), (i32 0), (i32 8))), sub1) 2099>; 2100 2101def : GCNPat < 2102 (i64 (DivergentSextInreg<i16> i64:$src)), 2103 (REG_SEQUENCE VReg_64, 2104 (V_BFE_I32_e64 (i32 (EXTRACT_SUBREG i64:$src, sub0)), (i32 0), (i32 16)), sub0, 2105 (V_ASHRREV_I32_e32 (i32 31), (V_BFE_I32_e64 (i32 (EXTRACT_SUBREG i64:$src, sub0)), (i32 0), (i32 16))), sub1) 2106>; 2107 2108def : GCNPat < 2109 (i64 (DivergentSextInreg<i32> i64:$src)), 2110 (REG_SEQUENCE VReg_64, 2111 (i32 (EXTRACT_SUBREG i64:$src, sub0)), sub0, 2112 (V_ASHRREV_I32_e32 (i32 31), (i32 (EXTRACT_SUBREG i64:$src, sub0))), sub1) 2113>; 2114 2115def : GCNPat < 2116 (i64 (zext i32:$src)), 2117 (REG_SEQUENCE SReg_64, $src, sub0, (S_MOV_B32 (i32 0)), sub1) 2118>; 2119 2120def : GCNPat < 2121 (i64 (anyext i32:$src)), 2122 (REG_SEQUENCE SReg_64, $src, sub0, (i32 (IMPLICIT_DEF)), sub1) 2123>; 2124 2125class ZExt_i64_i1_Pat <SDNode ext> : GCNPat < 2126 (i64 (ext i1:$src)), 2127 (REG_SEQUENCE VReg_64, 2128 (V_CNDMASK_B32_e64 /*src0mod*/(i32 0), /*src0*/(i32 0), 2129 /*src1mod*/(i32 0), /*src1*/(i32 1), $src), 2130 sub0, (S_MOV_B32 (i32 0)), sub1) 2131>; 2132 2133 2134def : ZExt_i64_i1_Pat<zext>; 2135def : ZExt_i64_i1_Pat<anyext>; 2136 2137// FIXME: We need to use COPY_TO_REGCLASS to work-around the fact that 2138// REG_SEQUENCE patterns don't support instructions with multiple outputs. 2139def : GCNPat < 2140 (i64 (UniformUnaryFrag<sext> i32:$src)), 2141 (REG_SEQUENCE SReg_64, $src, sub0, 2142 (i32 (COPY_TO_REGCLASS (S_ASHR_I32 $src, (i32 31)), SReg_32_XM0)), sub1) 2143>; 2144 2145def : GCNPat < 2146 (i64 (DivergentUnaryFrag<sext> i32:$src)), 2147 (REG_SEQUENCE VReg_64, $src, sub0, 2148 (i32 (COPY_TO_REGCLASS (V_ASHRREV_I32_e64 (i32 31), $src), VGPR_32)), sub1) 2149>; 2150 2151def : GCNPat < 2152 (i64 (sext i1:$src)), 2153 (REG_SEQUENCE VReg_64, 2154 (V_CNDMASK_B32_e64 /*src0mod*/(i32 0), /*src0*/(i32 0), 2155 /*src1mod*/(i32 0), /*src1*/(i32 -1), $src), sub0, 2156 (V_CNDMASK_B32_e64 /*src0mod*/(i32 0), /*src0*/(i32 0), 2157 /*src1mod*/(i32 0), /*src1*/(i32 -1), $src), sub1) 2158>; 2159 2160class FPToI1Pat<Instruction Inst, int KOne, ValueType kone_type, ValueType vt, SDPatternOperator fp_to_int> : GCNPat < 2161 (i1 (fp_to_int (vt (VOP3Mods vt:$src0, i32:$src0_modifiers)))), 2162 (i1 (Inst 0, (kone_type KOne), $src0_modifiers, $src0, DSTCLAMP.NONE)) 2163>; 2164 2165def : FPToI1Pat<V_CMP_EQ_F16_e64, CONST.FP16_ONE, i16, f16, fp_to_uint>; 2166def : FPToI1Pat<V_CMP_EQ_F16_e64, CONST.FP16_NEG_ONE, i16, f16, fp_to_sint>; 2167def : FPToI1Pat<V_CMP_EQ_F32_e64, CONST.FP32_ONE, i32, f32, fp_to_uint>; 2168def : FPToI1Pat<V_CMP_EQ_F32_e64, CONST.FP32_NEG_ONE, i32, f32, fp_to_sint>; 2169def : FPToI1Pat<V_CMP_EQ_F64_e64, CONST.FP64_ONE, i64, f64, fp_to_uint>; 2170def : FPToI1Pat<V_CMP_EQ_F64_e64, CONST.FP64_NEG_ONE, i64, f64, fp_to_sint>; 2171 2172// If we need to perform a logical operation on i1 values, we need to 2173// use vector comparisons since there is only one SCC register. Vector 2174// comparisons may write to a pair of SGPRs or a single SGPR, so treat 2175// these as 32 or 64-bit comparisons. When legalizing SGPR copies, 2176// instructions resulting in the copies from SCC to these instructions 2177// will be moved to the VALU. 2178 2179let WaveSizePredicate = isWave64 in { 2180def : GCNPat < 2181 (i1 (and i1:$src0, i1:$src1)), 2182 (S_AND_B64 $src0, $src1) 2183>; 2184 2185def : GCNPat < 2186 (i1 (or i1:$src0, i1:$src1)), 2187 (S_OR_B64 $src0, $src1) 2188>; 2189 2190def : GCNPat < 2191 (i1 (xor i1:$src0, i1:$src1)), 2192 (S_XOR_B64 $src0, $src1) 2193>; 2194 2195def : GCNPat < 2196 (i1 (add i1:$src0, i1:$src1)), 2197 (S_XOR_B64 $src0, $src1) 2198>; 2199 2200def : GCNPat < 2201 (i1 (sub i1:$src0, i1:$src1)), 2202 (S_XOR_B64 $src0, $src1) 2203>; 2204 2205let AddedComplexity = 1 in { 2206def : GCNPat < 2207 (i1 (add i1:$src0, (i1 -1))), 2208 (S_NOT_B64 $src0) 2209>; 2210 2211def : GCNPat < 2212 (i1 (sub i1:$src0, (i1 -1))), 2213 (S_NOT_B64 $src0) 2214>; 2215} 2216} // end isWave64 2217 2218let WaveSizePredicate = isWave32 in { 2219def : GCNPat < 2220 (i1 (and i1:$src0, i1:$src1)), 2221 (S_AND_B32 $src0, $src1) 2222>; 2223 2224def : GCNPat < 2225 (i1 (or i1:$src0, i1:$src1)), 2226 (S_OR_B32 $src0, $src1) 2227>; 2228 2229def : GCNPat < 2230 (i1 (xor i1:$src0, i1:$src1)), 2231 (S_XOR_B32 $src0, $src1) 2232>; 2233 2234def : GCNPat < 2235 (i1 (add i1:$src0, i1:$src1)), 2236 (S_XOR_B32 $src0, $src1) 2237>; 2238 2239def : GCNPat < 2240 (i1 (sub i1:$src0, i1:$src1)), 2241 (S_XOR_B32 $src0, $src1) 2242>; 2243 2244let AddedComplexity = 1 in { 2245def : GCNPat < 2246 (i1 (add i1:$src0, (i1 -1))), 2247 (S_NOT_B32 $src0) 2248>; 2249 2250def : GCNPat < 2251 (i1 (sub i1:$src0, (i1 -1))), 2252 (S_NOT_B32 $src0) 2253>; 2254} 2255} // end isWave32 2256 2257def : GCNPat < 2258 (i32 (DivergentBinFrag<xor> i32:$src0, (i32 -1))), 2259 (V_NOT_B32_e32 $src0) 2260>; 2261 2262def : GCNPat < 2263 (i64 (DivergentBinFrag<xor> i64:$src0, (i64 -1))), 2264 (REG_SEQUENCE VReg_64, 2265 (V_NOT_B32_e32 (i32 (EXTRACT_SUBREG i64:$src0, sub0))), sub0, 2266 (V_NOT_B32_e32 (i32 (EXTRACT_SUBREG i64:$src0, sub1))), sub1 2267 ) 2268>; 2269 2270def : GCNPat < 2271 (f16 (sint_to_fp i1:$src)), 2272 (V_CVT_F16_F32_e32 ( 2273 V_CNDMASK_B32_e64 /*src0mod*/(i32 0), /*src0*/(i32 0), 2274 /*src1mod*/(i32 0), /*src1*/(i32 CONST.FP32_NEG_ONE), 2275 SSrc_i1:$src)) 2276>; 2277 2278def : GCNPat < 2279 (f16 (uint_to_fp i1:$src)), 2280 (V_CVT_F16_F32_e32 ( 2281 V_CNDMASK_B32_e64 /*src0mod*/(i32 0), /*src0*/(i32 0), 2282 /*src1mod*/(i32 0), /*src1*/(i32 CONST.FP32_ONE), 2283 SSrc_i1:$src)) 2284>; 2285 2286def : GCNPat < 2287 (f32 (sint_to_fp i1:$src)), 2288 (V_CNDMASK_B32_e64 /*src0mod*/(i32 0), /*src0*/(i32 0), 2289 /*src1mod*/(i32 0), /*src1*/(i32 CONST.FP32_NEG_ONE), 2290 SSrc_i1:$src) 2291>; 2292 2293def : GCNPat < 2294 (f32 (uint_to_fp i1:$src)), 2295 (V_CNDMASK_B32_e64 /*src0mod*/(i32 0), /*src0*/(i32 0), 2296 /*src1mod*/(i32 0), /*src1*/(i32 CONST.FP32_ONE), 2297 SSrc_i1:$src) 2298>; 2299 2300def : GCNPat < 2301 (f64 (sint_to_fp i1:$src)), 2302 (V_CVT_F64_I32_e32 (V_CNDMASK_B32_e64 /*src0mod*/(i32 0), /*src0*/(i32 0), 2303 /*src1mod*/(i32 0), /*src1*/(i32 -1), 2304 SSrc_i1:$src)) 2305>; 2306 2307def : GCNPat < 2308 (f64 (uint_to_fp i1:$src)), 2309 (V_CVT_F64_U32_e32 (V_CNDMASK_B32_e64 /*src0mod*/(i32 0), /*src0*/(i32 0), 2310 /*src1mod*/(i32 0), /*src1*/(i32 1), 2311 SSrc_i1:$src)) 2312>; 2313 2314//===----------------------------------------------------------------------===// 2315// Miscellaneous Patterns 2316//===----------------------------------------------------------------------===// 2317 2318// Eliminate a zero extension from an fp16 operation if it already 2319// zeros the high bits of the 32-bit register. 2320// 2321// This is complicated on gfx9+. Some instructions maintain the legacy 2322// zeroing behavior, but others preserve the high bits. Some have a 2323// control bit to change the behavior. We can't simply say with 2324// certainty what the source behavior is without more context on how 2325// the src is lowered. e.g. fptrunc + fma may be lowered to a 2326// v_fma_mix* instruction which does not zero, or may not. 2327def : GCNPat< 2328 (i32 (DivergentUnaryFrag<abs> i32:$src)), 2329 (V_MAX_I32_e64 (V_SUB_CO_U32_e32 (i32 0), $src), $src)>; 2330 2331let AddedComplexity = 1 in { 2332def : GCNPat< 2333 (i32 (DivergentUnaryFrag<abs> i32:$src)), 2334 (V_MAX_I32_e64 (V_SUB_U32_e32 (i32 0), $src), $src)>{ 2335 let SubtargetPredicate = HasAddNoCarryInsts; 2336} 2337} // AddedComplexity = 1 2338 2339def : GCNPat< 2340 (i32 (DivergentUnaryFrag<zext> i16:$src)), 2341 (V_AND_B32_e64 (S_MOV_B32 (i32 0xffff)), $src) 2342>; 2343 2344def : GCNPat< 2345 (i64 (DivergentUnaryFrag<zext> i16:$src)), 2346 (REG_SEQUENCE VReg_64, 2347 (V_AND_B32_e64 (S_MOV_B32 (i32 0xffff)), $src), sub0, 2348 (S_MOV_B32 (i32 0)), sub1) 2349>; 2350 2351def : GCNPat< 2352 (i32 (zext (i16 (bitconvert fp16_zeros_high_16bits:$src)))), 2353 (COPY VSrc_b16:$src)>; 2354 2355def : GCNPat < 2356 (i32 (trunc i64:$a)), 2357 (EXTRACT_SUBREG $a, sub0) 2358>; 2359 2360def : GCNPat < 2361 (i1 (UniformUnaryFrag<trunc> i32:$a)), 2362 (S_CMP_EQ_U32 (S_AND_B32 (i32 1), $a), (i32 1)) 2363>; 2364 2365def : GCNPat < 2366 (i1 (UniformUnaryFrag<trunc> i16:$a)), 2367 (S_CMP_EQ_U32 (S_AND_B32 (i32 1), $a), (i32 1)) 2368>; 2369 2370def : GCNPat < 2371 (i1 (UniformUnaryFrag<trunc> i64:$a)), 2372 (S_CMP_EQ_U32 (S_AND_B32 (i32 1), 2373 (i32 (EXTRACT_SUBREG $a, sub0))), (i32 1)) 2374>; 2375 2376def : GCNPat < 2377 (i1 (DivergentUnaryFrag<trunc> i32:$a)), 2378 (V_CMP_EQ_U32_e64 (V_AND_B32_e64 (i32 1), $a), (i32 1)) 2379>; 2380 2381def : GCNPat < 2382 (i1 (DivergentUnaryFrag<trunc> i16:$a)), 2383 (V_CMP_EQ_U32_e64 (V_AND_B32_e64 (i32 1), $a), (i32 1)) 2384>; 2385 2386def IMMBitSelConst : SDNodeXForm<imm, [{ 2387 return CurDAG->getTargetConstant(1ULL << N->getZExtValue(), SDLoc(N), 2388 MVT::i32); 2389}]>; 2390 2391// Matching separate SRL and TRUNC instructions 2392// with dependent operands (SRL dest is source of TRUNC) 2393// generates three instructions. However, by using bit shifts, 2394// the V_LSHRREV_B32_e64 result can be directly used in the 2395// operand of the V_AND_B32_e64 instruction: 2396// (trunc i32 (srl i32 $a, i32 $b)) -> 2397// v_and_b32_e64 $a, (1 << $b), $a 2398// v_cmp_ne_u32_e64 $a, 0, $a 2399 2400// Handle the VALU case. 2401def : GCNPat < 2402 (i1 (DivergentUnaryFrag<trunc> (i32 (srl i32:$a, (i32 imm:$b))))), 2403 (V_CMP_NE_U32_e64 (V_AND_B32_e64 (i32 (IMMBitSelConst $b)), $a), 2404 (i32 0)) 2405>; 2406 2407// Handle the scalar case. 2408def : GCNPat < 2409 (i1 (UniformUnaryFrag<trunc> (i32 (srl i32:$a, (i32 imm:$b))))), 2410 (S_CMP_LG_U32 (S_AND_B32 (i32 (IMMBitSelConst $b)), $a), 2411 (i32 0)) 2412>; 2413 2414def : GCNPat < 2415 (i1 (DivergentUnaryFrag<trunc> i64:$a)), 2416 (V_CMP_EQ_U32_e64 (V_AND_B32_e64 (i32 1), 2417 (i32 (EXTRACT_SUBREG $a, sub0))), (i32 1)) 2418>; 2419 2420def : GCNPat < 2421 (i32 (bswap i32:$a)), 2422 (V_BFI_B32_e64 (S_MOV_B32 (i32 0x00ff00ff)), 2423 (V_ALIGNBIT_B32_e64 VSrc_b32:$a, VSrc_b32:$a, (i32 24)), 2424 (V_ALIGNBIT_B32_e64 VSrc_b32:$a, VSrc_b32:$a, (i32 8))) 2425>; 2426 2427// FIXME: This should have been narrowed to i32 during legalization. 2428// This pattern should also be skipped for GlobalISel 2429def : GCNPat < 2430 (i64 (bswap i64:$a)), 2431 (REG_SEQUENCE VReg_64, 2432 (V_BFI_B32_e64 (S_MOV_B32 (i32 0x00ff00ff)), 2433 (V_ALIGNBIT_B32_e64 (i32 (EXTRACT_SUBREG VReg_64:$a, sub1)), 2434 (i32 (EXTRACT_SUBREG VReg_64:$a, sub1)), 2435 (i32 24)), 2436 (V_ALIGNBIT_B32_e64 (i32 (EXTRACT_SUBREG VReg_64:$a, sub1)), 2437 (i32 (EXTRACT_SUBREG VReg_64:$a, sub1)), 2438 (i32 8))), 2439 sub0, 2440 (V_BFI_B32_e64 (S_MOV_B32 (i32 0x00ff00ff)), 2441 (V_ALIGNBIT_B32_e64 (i32 (EXTRACT_SUBREG VReg_64:$a, sub0)), 2442 (i32 (EXTRACT_SUBREG VReg_64:$a, sub0)), 2443 (i32 24)), 2444 (V_ALIGNBIT_B32_e64 (i32 (EXTRACT_SUBREG VReg_64:$a, sub0)), 2445 (i32 (EXTRACT_SUBREG VReg_64:$a, sub0)), 2446 (i32 8))), 2447 sub1) 2448>; 2449 2450// FIXME: The AddedComplexity should not be needed, but in GlobalISel 2451// the BFI pattern ends up taking precedence without it. 2452let SubtargetPredicate = isGFX8Plus, AddedComplexity = 1 in { 2453// Magic number: 3 | (2 << 8) | (1 << 16) | (0 << 24) 2454// 2455// My reading of the manual suggests we should be using src0 for the 2456// register value, but this is what seems to work. 2457def : GCNPat < 2458 (i32 (bswap i32:$a)), 2459 (V_PERM_B32_e64 (i32 0), VSrc_b32:$a, (S_MOV_B32 (i32 0x00010203))) 2460>; 2461 2462// FIXME: This should have been narrowed to i32 during legalization. 2463// This pattern should also be skipped for GlobalISel 2464def : GCNPat < 2465 (i64 (bswap i64:$a)), 2466 (REG_SEQUENCE VReg_64, 2467 (V_PERM_B32_e64 (i32 0), (EXTRACT_SUBREG VReg_64:$a, sub1), 2468 (S_MOV_B32 (i32 0x00010203))), 2469 sub0, 2470 (V_PERM_B32_e64 (i32 0), (EXTRACT_SUBREG VReg_64:$a, sub0), 2471 (S_MOV_B32 (i32 0x00010203))), 2472 sub1) 2473>; 2474 2475// Magic number: 1 | (0 << 8) | (12 << 16) | (12 << 24) 2476// The 12s emit 0s. 2477def : GCNPat < 2478 (i16 (bswap i16:$a)), 2479 (V_PERM_B32_e64 (i32 0), VSrc_b32:$a, (S_MOV_B32 (i32 0x0c0c0001))) 2480>; 2481 2482def : GCNPat < 2483 (i32 (zext (bswap i16:$a))), 2484 (V_PERM_B32_e64 (i32 0), VSrc_b32:$a, (S_MOV_B32 (i32 0x0c0c0001))) 2485>; 2486 2487// Magic number: 1 | (0 << 8) | (3 << 16) | (2 << 24) 2488def : GCNPat < 2489 (v2i16 (bswap v2i16:$a)), 2490 (V_PERM_B32_e64 (i32 0), VSrc_b32:$a, (S_MOV_B32 (i32 0x02030001))) 2491>; 2492 2493} 2494 2495def : GCNPat< 2496 (i64 (DivergentUnaryFrag<bitreverse> i64:$a)), 2497 (REG_SEQUENCE VReg_64, 2498 (V_BFREV_B32_e64 (i32 (EXTRACT_SUBREG VReg_64:$a, sub1))), sub0, 2499 (V_BFREV_B32_e64 (i32 (EXTRACT_SUBREG VReg_64:$a, sub0))), sub1)>; 2500 2501// Prefer selecting to max when legal, but using mul is always valid. 2502let AddedComplexity = -5 in { 2503def : GCNPat< 2504 (fcanonicalize (f16 (VOP3Mods f16:$src, i32:$src_mods))), 2505 (V_MUL_F16_e64 0, (i32 CONST.FP16_ONE), $src_mods, $src) 2506>; 2507 2508def : GCNPat< 2509 (fcanonicalize (f16 (fneg (VOP3Mods f16:$src, i32:$src_mods)))), 2510 (V_MUL_F16_e64 0, (i32 CONST.FP16_NEG_ONE), $src_mods, $src) 2511>; 2512 2513def : GCNPat< 2514 (fcanonicalize (v2f16 (VOP3PMods v2f16:$src, i32:$src_mods))), 2515 (V_PK_MUL_F16 0, (i32 CONST.FP16_ONE), $src_mods, $src, DSTCLAMP.NONE) 2516>; 2517 2518def : GCNPat< 2519 (fcanonicalize (f32 (VOP3Mods f32:$src, i32:$src_mods))), 2520 (V_MUL_F32_e64 0, (i32 CONST.FP32_ONE), $src_mods, $src) 2521>; 2522 2523def : GCNPat< 2524 (fcanonicalize (f32 (fneg (VOP3Mods f32:$src, i32:$src_mods)))), 2525 (V_MUL_F32_e64 0, (i32 CONST.FP32_NEG_ONE), $src_mods, $src) 2526>; 2527 2528// TODO: Handle fneg like other types. 2529def : GCNPat< 2530 (fcanonicalize (f64 (VOP3Mods f64:$src, i32:$src_mods))), 2531 (V_MUL_F64_e64 0, CONST.FP64_ONE, $src_mods, $src) 2532>; 2533} // End AddedComplexity = -5 2534 2535multiclass SelectCanonicalizeAsMax< 2536 list<Predicate> f32_preds = [], 2537 list<Predicate> f64_preds = [], 2538 list<Predicate> f16_preds = []> { 2539 def : GCNPat< 2540 (fcanonicalize (f32 (VOP3Mods f32:$src, i32:$src_mods))), 2541 (V_MAX_F32_e64 $src_mods, $src, $src_mods, $src)> { 2542 let OtherPredicates = f32_preds; 2543 } 2544 2545 def : GCNPat< 2546 (fcanonicalize (f64 (VOP3Mods f64:$src, i32:$src_mods))), 2547 (V_MAX_F64_e64 $src_mods, $src, $src_mods, $src)> { 2548 let OtherPredicates = f64_preds; 2549 } 2550 2551 def : GCNPat< 2552 (fcanonicalize (f16 (VOP3Mods f16:$src, i32:$src_mods))), 2553 (V_MAX_F16_e64 $src_mods, $src, $src_mods, $src, 0, 0)> { 2554 // FIXME: Should have 16-bit inst subtarget predicate 2555 let OtherPredicates = f16_preds; 2556 } 2557 2558 def : GCNPat< 2559 (fcanonicalize (v2f16 (VOP3PMods v2f16:$src, i32:$src_mods))), 2560 (V_PK_MAX_F16 $src_mods, $src, $src_mods, $src, DSTCLAMP.NONE)> { 2561 // FIXME: Should have VOP3P subtarget predicate 2562 let OtherPredicates = f16_preds; 2563 } 2564} 2565 2566// On pre-gfx9 targets, v_max_*/v_min_* did not respect the denormal 2567// mode, and would never flush. For f64, it's faster to do implement 2568// this with a max. For f16/f32 it's a wash, but prefer max when 2569// valid. 2570// 2571// FIXME: Lowering f32/f16 with max is worse since we can use a 2572// smaller encoding if the input is fneg'd. It also adds an extra 2573// register use. 2574let SubtargetPredicate = HasMinMaxDenormModes in { 2575 defm : SelectCanonicalizeAsMax<[], [], []>; 2576} // End SubtargetPredicate = HasMinMaxDenormModes 2577 2578let SubtargetPredicate = NotHasMinMaxDenormModes in { 2579 // Use the max lowering if we don't need to flush. 2580 2581 // FIXME: We don't do use this for f32 as a workaround for the 2582 // library being compiled with the default ieee mode, but 2583 // potentially being called from flushing kernels. Really we should 2584 // not be mixing code expecting different default FP modes, but mul 2585 // works in any FP environment. 2586 defm : SelectCanonicalizeAsMax<[FalsePredicate], [FP64Denormals], [FP16Denormals]>; 2587} // End SubtargetPredicate = NotHasMinMaxDenormModes 2588 2589 2590let OtherPredicates = [HasDLInsts] in { 2591// Don't allow source modifiers. If there are any source modifiers then it's 2592// better to select fma instead of fmac. 2593def : GCNPat < 2594 (fma (f32 (VOP3NoMods f32:$src0)), 2595 (f32 (VOP3NoMods f32:$src1)), 2596 (f32 (VOP3NoMods f32:$src2))), 2597 (V_FMAC_F32_e64 SRCMODS.NONE, $src0, SRCMODS.NONE, $src1, 2598 SRCMODS.NONE, $src2) 2599>; 2600} // End OtherPredicates = [HasDLInsts] 2601 2602let SubtargetPredicate = isGFX10Plus in 2603// Don't allow source modifiers. If there are any source modifiers then it's 2604// better to select fma instead of fmac. 2605def : GCNPat < 2606 (fma (f16 (VOP3NoMods f32:$src0)), 2607 (f16 (VOP3NoMods f32:$src1)), 2608 (f16 (VOP3NoMods f32:$src2))), 2609 (V_FMAC_F16_e64 SRCMODS.NONE, $src0, SRCMODS.NONE, $src1, 2610 SRCMODS.NONE, $src2) 2611>; 2612 2613let SubtargetPredicate = isGFX90APlus in 2614// Don't allow source modifiers. If there are any source modifiers then it's 2615// better to select fma instead of fmac. 2616def : GCNPat < 2617 (fma (f64 (VOP3NoMods f64:$src0)), 2618 (f64 (VOP3NoMods f64:$src1)), 2619 (f64 (VOP3NoMods f64:$src2))), 2620 (V_FMAC_F64_e64 SRCMODS.NONE, $src0, SRCMODS.NONE, $src1, 2621 SRCMODS.NONE, $src2) 2622>; 2623 2624// COPY is workaround tablegen bug from multiple outputs 2625// from S_LSHL_B32's multiple outputs from implicit scc def. 2626def : GCNPat < 2627 (v2i16 (UniformBinFrag<build_vector> (i16 0), (i16 SReg_32:$src1))), 2628 (S_LSHL_B32 SReg_32:$src1, (i16 16)) 2629>; 2630 2631def : GCNPat < 2632 (v2i16 (DivergentBinFrag<build_vector> (i16 0), (i16 SReg_32:$src1))), 2633 (v2i16 (V_LSHLREV_B32_e64 (i16 16), SReg_32:$src1)) 2634>; 2635 2636 2637def : GCNPat < 2638 (v2i16 (UniformBinFrag<build_vector> (i16 SReg_32:$src1), (i16 0))), 2639 (S_AND_B32 (S_MOV_B32 (i32 0xffff)), SReg_32:$src1) 2640>; 2641 2642def : GCNPat < 2643 (v2i16 (DivergentBinFrag<build_vector> (i16 SReg_32:$src1), (i16 0))), 2644 (v2i16 (V_AND_B32_e64 (i32 (V_MOV_B32_e32 (i32 0xffff))), SReg_32:$src1)) 2645>; 2646 2647def : GCNPat < 2648 (v2f16 (UniformBinFrag<build_vector> (f16 SReg_32:$src1), (f16 FP_ZERO))), 2649 (S_AND_B32 (S_MOV_B32 (i32 0xffff)), SReg_32:$src1) 2650>; 2651 2652def : GCNPat < 2653 (v2f16 (DivergentBinFrag<build_vector> (f16 SReg_32:$src1), (f16 FP_ZERO))), 2654 (v2f16 (V_AND_B32_e64 (i32 (V_MOV_B32_e32 (i32 0xffff))), SReg_32:$src1)) 2655>; 2656 2657def : GCNPat < 2658 (v2i16 (UniformBinFrag<build_vector> (i16 SReg_32:$src0), (i16 undef))), 2659 (COPY_TO_REGCLASS SReg_32:$src0, SReg_32) 2660>; 2661 2662def : GCNPat < 2663 (v2i16 (DivergentBinFrag<build_vector> (i16 VGPR_32:$src0), (i16 undef))), 2664 (COPY_TO_REGCLASS VGPR_32:$src0, VGPR_32) 2665>; 2666 2667def : GCNPat < 2668 (v2f16 (build_vector f16:$src0, (f16 undef))), 2669 (COPY $src0) 2670>; 2671 2672def : GCNPat < 2673 (v2i16 (UniformBinFrag<build_vector> (i16 undef), (i16 SReg_32:$src1))), 2674 (S_LSHL_B32 SReg_32:$src1, (i32 16)) 2675>; 2676 2677def : GCNPat < 2678 (v2i16 (DivergentBinFrag<build_vector> (i16 undef), (i16 SReg_32:$src1))), 2679 (v2i16 (V_LSHLREV_B32_e64 (i32 16), SReg_32:$src1)) 2680>; 2681 2682 2683def : GCNPat < 2684 (v2f16 (UniformBinFrag<build_vector> (f16 undef), (f16 SReg_32:$src1))), 2685 (S_LSHL_B32 SReg_32:$src1, (i32 16)) 2686>; 2687 2688def : GCNPat < 2689 (v2f16 (DivergentBinFrag<build_vector> (f16 undef), (f16 SReg_32:$src1))), 2690 (v2f16 (V_LSHLREV_B32_e64 (i32 16), SReg_32:$src1)) 2691>; 2692 2693let SubtargetPredicate = HasVOP3PInsts in { 2694def : GCNPat < 2695 (v2i16 (UniformBinFrag<build_vector> (i16 SReg_32:$src0), (i16 SReg_32:$src1))), 2696 (S_PACK_LL_B32_B16 SReg_32:$src0, SReg_32:$src1) 2697>; 2698 2699def : GCNPat < 2700 (v2i16 (DivergentBinFrag<build_vector> (i16 SReg_32:$src0), (i16 SReg_32:$src1))), 2701 (v2i16 (V_LSHL_OR_B32_e64 $src1, (i32 16), (i32 (V_AND_B32_e64 (i32 (V_MOV_B32_e32 (i32 0xffff))), $src0)))) 2702>; 2703 2704// With multiple uses of the shift, this will duplicate the shift and 2705// increase register pressure. 2706def : GCNPat < 2707 (v2i16 (UniformBinFrag<build_vector> (i16 SReg_32:$src0), (i16 (trunc (srl_oneuse SReg_32:$src1, (i32 16)))))), 2708 (v2i16 (S_PACK_LH_B32_B16 SReg_32:$src0, SReg_32:$src1)) 2709>; 2710 2711def : GCNPat < 2712 (v2i16 (DivergentBinFrag<build_vector> (i16 SReg_32:$src0), (i16 (trunc (srl_oneuse SReg_32:$src1, (i32 16)))))), 2713 (v2i16 (V_BFI_B32_e64 (i32 (V_MOV_B32_e32 (i32 0xffff))), SReg_32:$src0, SReg_32:$src1)) 2714>; 2715 2716 2717def : GCNPat < 2718 (v2i16 (UniformBinFrag<build_vector> (i16 (trunc (srl_oneuse SReg_32:$src0, (i32 16)))), 2719 (i16 (trunc (srl_oneuse SReg_32:$src1, (i32 16)))))), 2720 (S_PACK_HH_B32_B16 SReg_32:$src0, SReg_32:$src1) 2721>; 2722 2723def : GCNPat < 2724 (v2i16 (DivergentBinFrag<build_vector> (i16 (trunc (srl_oneuse SReg_32:$src0, (i32 16)))), 2725 (i16 (trunc (srl_oneuse SReg_32:$src1, (i32 16)))))), 2726 (v2i16 (V_AND_OR_B32_e64 SReg_32:$src1, (i32 (V_MOV_B32_e32 (i32 0xffff0000))), (i32 (V_LSHRREV_B32_e64 (i32 16), SReg_32:$src0)))) 2727>; 2728 2729def : GCNPat < 2730 (v2f16 (UniformBinFrag<build_vector> (f16 SReg_32:$src0), (f16 SReg_32:$src1))), 2731 (S_PACK_LL_B32_B16 SReg_32:$src0, SReg_32:$src1) 2732>; 2733 2734def : GCNPat < 2735 (v2f16 (DivergentBinFrag<build_vector> (f16 SReg_32:$src0), (f16 SReg_32:$src1))), 2736 (v2f16 (V_LSHL_OR_B32_e64 SReg_32:$src1, (i32 16), (i32 (V_AND_B32_e64 (i32 (V_MOV_B32_e32 (i32 0xffff))), SReg_32:$src0)))) 2737>; 2738 2739 2740def : GCNPat < 2741 (v2f16 (is_canonicalized<build_vector> (f16 (VOP3Mods (f16 VGPR_32:$src0), i32:$src0_mods)), 2742 (f16 (VOP3Mods (f16 VGPR_32:$src1), i32:$src1_mods)))), 2743 (V_PACK_B32_F16_e64 $src0_mods, VGPR_32:$src0, $src1_mods, VGPR_32:$src1) 2744>; 2745} // End SubtargetPredicate = HasVOP3PInsts 2746 2747// With multiple uses of the shift, this will duplicate the shift and 2748// increase register pressure. 2749let SubtargetPredicate = isGFX11Plus in 2750def : GCNPat < 2751 (v2i16 (build_vector (i16 (trunc (srl_oneuse SReg_32:$src0, (i32 16)))), (i16 SReg_32:$src1))), 2752 (v2i16 (S_PACK_HL_B32_B16 SReg_32:$src0, SReg_32:$src1)) 2753>; 2754 2755 2756def : GCNPat < 2757 (v2f16 (scalar_to_vector f16:$src0)), 2758 (COPY $src0) 2759>; 2760 2761def : GCNPat < 2762 (v2i16 (scalar_to_vector i16:$src0)), 2763 (COPY $src0) 2764>; 2765 2766def : GCNPat < 2767 (v4i16 (scalar_to_vector i16:$src0)), 2768 (INSERT_SUBREG (IMPLICIT_DEF), $src0, sub0) 2769>; 2770 2771def : GCNPat < 2772 (v4f16 (scalar_to_vector f16:$src0)), 2773 (INSERT_SUBREG (IMPLICIT_DEF), $src0, sub0) 2774>; 2775 2776def : GCNPat < 2777 (i64 (int_amdgcn_mov_dpp i64:$src, timm:$dpp_ctrl, timm:$row_mask, 2778 timm:$bank_mask, timm:$bound_ctrl)), 2779 (V_MOV_B64_DPP_PSEUDO VReg_64_Align2:$src, VReg_64_Align2:$src, 2780 (as_i32timm $dpp_ctrl), (as_i32timm $row_mask), 2781 (as_i32timm $bank_mask), 2782 (as_i1timm $bound_ctrl)) 2783>; 2784 2785def : GCNPat < 2786 (i64 (int_amdgcn_update_dpp i64:$old, i64:$src, timm:$dpp_ctrl, timm:$row_mask, 2787 timm:$bank_mask, timm:$bound_ctrl)), 2788 (V_MOV_B64_DPP_PSEUDO VReg_64_Align2:$old, VReg_64_Align2:$src, (as_i32timm $dpp_ctrl), 2789 (as_i32timm $row_mask), (as_i32timm $bank_mask), 2790 (as_i1timm $bound_ctrl)) 2791>; 2792 2793//===----------------------------------------------------------------------===// 2794// Fract Patterns 2795//===----------------------------------------------------------------------===// 2796 2797let SubtargetPredicate = isGFX6 in { 2798 2799// V_FRACT is buggy on SI, so the F32 version is never used and (x-floor(x)) is 2800// used instead. However, SI doesn't have V_FLOOR_F64, so the most efficient 2801// way to implement it is using V_FRACT_F64. 2802// The workaround for the V_FRACT bug is: 2803// fract(x) = isnan(x) ? x : min(V_FRACT(x), 0.99999999999999999) 2804 2805// Convert floor(x) to (x - fract(x)) 2806 2807// Don't bother handling this for GlobalISel, it's handled during 2808// lowering. 2809// 2810// FIXME: DAG should also custom lower this. 2811def : GCNPat < 2812 (f64 (ffloor (f64 (VOP3Mods f64:$x, i32:$mods)))), 2813 (V_ADD_F64_e64 2814 $mods, 2815 $x, 2816 SRCMODS.NEG, 2817 (V_CNDMASK_B64_PSEUDO 2818 (V_MIN_F64_e64 2819 SRCMODS.NONE, 2820 (V_FRACT_F64_e64 $mods, $x), 2821 SRCMODS.NONE, 2822 (V_MOV_B64_PSEUDO 0x3fefffffffffffff)), 2823 $x, 2824 (V_CMP_CLASS_F64_e64 SRCMODS.NONE, $x, (i32 3 /*NaN*/)))) 2825>; 2826 2827} // End SubtargetPredicates = isGFX6 2828 2829//============================================================================// 2830// Miscellaneous Optimization Patterns 2831//============================================================================// 2832 2833// Undo sub x, c -> add x, -c canonicalization since c is more likely 2834// an inline immediate than -c. 2835// TODO: Also do for 64-bit. 2836def : GCNPat< 2837 (UniformBinFrag<add> i32:$src0, (i32 NegSubInlineConst32:$src1)), 2838 (S_SUB_I32 SReg_32:$src0, NegSubInlineConst32:$src1) 2839>; 2840 2841def : GCNPat< 2842 (DivergentBinFrag<add> i32:$src0, (i32 NegSubInlineConst32:$src1)), 2843 (V_SUB_U32_e64 VS_32:$src0, NegSubInlineConst32:$src1)> { 2844 let SubtargetPredicate = HasAddNoCarryInsts; 2845} 2846 2847def : GCNPat< 2848 (DivergentBinFrag<add> i32:$src0, (i32 NegSubInlineConst32:$src1)), 2849 (V_SUB_CO_U32_e64 VS_32:$src0, NegSubInlineConst32:$src1)> { 2850 let SubtargetPredicate = NotHasAddNoCarryInsts; 2851} 2852 2853 2854// Avoid pointlessly materializing a constant in VGPR. 2855// FIXME: Should also do this for readlane, but tablegen crashes on 2856// the ignored src1. 2857def : GCNPat< 2858 (int_amdgcn_readfirstlane (i32 imm:$src)), 2859 (S_MOV_B32 SReg_32:$src) 2860>; 2861 2862multiclass BFMPatterns <ValueType vt, PatFrag SHL, PatFrag ADD, InstSI BFM> { 2863 def : GCNPat < 2864 (vt (SHL (vt (add (vt (shl 1, vt:$a)), -1)), vt:$b)), 2865 (BFM $a, $b) 2866 >; 2867 2868 def : GCNPat < 2869 (vt (ADD (vt (shl 1, vt:$a)), -1)), 2870 (BFM $a, (i32 0)) 2871 >; 2872} 2873 2874defm : BFMPatterns <i32, UniformBinFrag<shl>, UniformBinFrag<add>, S_BFM_B32>; 2875// FIXME: defm : BFMPatterns <i64, UniformBinFrag<shl>, UniformBinFrag<add>, S_BFM_B64>; 2876defm : BFMPatterns <i32, DivergentBinFrag<shl>, DivergentBinFrag<add>, V_BFM_B32_e64>; 2877 2878// Bitfield extract patterns 2879 2880def IMMZeroBasedBitfieldMask : ImmLeaf <i32, [{ 2881 return isMask_32(Imm); 2882}]>; 2883 2884def IMMPopCount : SDNodeXForm<imm, [{ 2885 return CurDAG->getTargetConstant(countPopulation(N->getZExtValue()), SDLoc(N), 2886 MVT::i32); 2887}]>; 2888 2889def : AMDGPUPat < 2890 (DivergentBinFrag<and> (i32 (srl i32:$src, i32:$rshift)), 2891 IMMZeroBasedBitfieldMask:$mask), 2892 (V_BFE_U32_e64 $src, $rshift, (i32 (IMMPopCount $mask))) 2893>; 2894 2895// x & ((1 << y) - 1) 2896def : AMDGPUPat < 2897 (DivergentBinFrag<and> i32:$src, (add_oneuse (shl_oneuse 1, i32:$width), -1)), 2898 (V_BFE_U32_e64 $src, (i32 0), $width) 2899>; 2900 2901// x & ~(-1 << y) 2902def : AMDGPUPat < 2903 (DivergentBinFrag<and> i32:$src, 2904 (xor_oneuse (shl_oneuse -1, i32:$width), -1)), 2905 (V_BFE_U32_e64 $src, (i32 0), $width) 2906>; 2907 2908// x & (-1 >> (bitwidth - y)) 2909def : AMDGPUPat < 2910 (DivergentBinFrag<and> i32:$src, (srl_oneuse -1, (sub 32, i32:$width))), 2911 (V_BFE_U32_e64 $src, (i32 0), $width) 2912>; 2913 2914// x << (bitwidth - y) >> (bitwidth - y) 2915def : AMDGPUPat < 2916 (DivergentBinFrag<srl> (shl_oneuse i32:$src, (sub 32, i32:$width)), 2917 (sub 32, i32:$width)), 2918 (V_BFE_U32_e64 $src, (i32 0), $width) 2919>; 2920 2921def : AMDGPUPat < 2922 (DivergentBinFrag<sra> (shl_oneuse i32:$src, (sub 32, i32:$width)), 2923 (sub 32, i32:$width)), 2924 (V_BFE_I32_e64 $src, (i32 0), $width) 2925>; 2926 2927// SHA-256 Ma patterns 2928 2929// ((x & z) | (y & (x | z))) -> BFI (XOR x, y), z, y 2930def : AMDGPUPat < 2931 (DivergentBinFrag<or> (and i32:$x, i32:$z), 2932 (and i32:$y, (or i32:$x, i32:$z))), 2933 (V_BFI_B32_e64 (V_XOR_B32_e64 VSrc_b32:$x, VSrc_b32:$y), VSrc_b32:$z, VSrc_b32:$y) 2934>; 2935 2936def : AMDGPUPat < 2937 (DivergentBinFrag<or> (and i64:$x, i64:$z), 2938 (and i64:$y, (or i64:$x, i64:$z))), 2939 (REG_SEQUENCE VReg_64, 2940 (V_BFI_B32_e64 (V_XOR_B32_e64 (i32 (EXTRACT_SUBREG VReg_64:$x, sub0)), 2941 (i32 (EXTRACT_SUBREG VReg_64:$y, sub0))), 2942 (i32 (EXTRACT_SUBREG VReg_64:$z, sub0)), 2943 (i32 (EXTRACT_SUBREG VReg_64:$y, sub0))), sub0, 2944 (V_BFI_B32_e64 (V_XOR_B32_e64 (i32 (EXTRACT_SUBREG VReg_64:$x, sub1)), 2945 (i32 (EXTRACT_SUBREG VReg_64:$y, sub1))), 2946 (i32 (EXTRACT_SUBREG VReg_64:$z, sub1)), 2947 (i32 (EXTRACT_SUBREG VReg_64:$y, sub1))), sub1) 2948>; 2949 2950multiclass IntMed3Pat<Instruction med3Inst, 2951 SDPatternOperator min, 2952 SDPatternOperator max, 2953 SDPatternOperator min_oneuse, 2954 SDPatternOperator max_oneuse> { 2955 2956 // This matches 16 permutations of 2957 // min(max(a, b), max(min(a, b), c)) 2958 def : AMDGPUPat < 2959 (min (max_oneuse i32:$src0, i32:$src1), 2960 (max_oneuse (min_oneuse i32:$src0, i32:$src1), i32:$src2)), 2961 (med3Inst VSrc_b32:$src0, VSrc_b32:$src1, VSrc_b32:$src2) 2962>; 2963 2964 // This matches 16 permutations of 2965 // max(min(x, y), min(max(x, y), z)) 2966 def : AMDGPUPat < 2967 (max (min_oneuse i32:$src0, i32:$src1), 2968 (min_oneuse (max_oneuse i32:$src0, i32:$src1), i32:$src2)), 2969 (med3Inst VSrc_b32:$src0, VSrc_b32:$src1, VSrc_b32:$src2) 2970>; 2971} 2972 2973defm : IntMed3Pat<V_MED3_I32_e64, smin, smax, smin_oneuse, smax_oneuse>; 2974defm : IntMed3Pat<V_MED3_U32_e64, umin, umax, umin_oneuse, umax_oneuse>; 2975 2976// This matches 16 permutations of 2977// max(min(x, y), min(max(x, y), z)) 2978class FPMed3Pat<ValueType vt, 2979 //SDPatternOperator max, SDPatternOperator min, 2980 Instruction med3Inst> : GCNPat< 2981 (fmaxnum_like (fminnum_like_oneuse (VOP3Mods_nnan vt:$src0, i32:$src0_mods), 2982 (VOP3Mods_nnan vt:$src1, i32:$src1_mods)), 2983 (fminnum_like_oneuse (fmaxnum_like_oneuse (VOP3Mods_nnan vt:$src0, i32:$src0_mods), 2984 (VOP3Mods_nnan vt:$src1, i32:$src1_mods)), 2985 (vt (VOP3Mods_nnan vt:$src2, i32:$src2_mods)))), 2986 (med3Inst $src0_mods, $src0, $src1_mods, $src1, $src2_mods, $src2, DSTCLAMP.NONE, DSTOMOD.NONE) 2987>; 2988 2989class FP16Med3Pat<ValueType vt, 2990 Instruction med3Inst> : GCNPat< 2991 (fmaxnum_like (fminnum_like_oneuse (VOP3Mods_nnan vt:$src0, i32:$src0_mods), 2992 (VOP3Mods_nnan vt:$src1, i32:$src1_mods)), 2993 (fminnum_like_oneuse (fmaxnum_like_oneuse (VOP3Mods_nnan vt:$src0, i32:$src0_mods), 2994 (VOP3Mods_nnan vt:$src1, i32:$src1_mods)), 2995 (vt (VOP3Mods_nnan vt:$src2, i32:$src2_mods)))), 2996 (med3Inst $src0_mods, $src0, $src1_mods, $src1, $src2_mods, $src2, DSTCLAMP.NONE) 2997>; 2998 2999multiclass Int16Med3Pat<Instruction med3Inst, 3000 SDPatternOperator min, 3001 SDPatternOperator max, 3002 SDPatternOperator max_oneuse, 3003 SDPatternOperator min_oneuse> { 3004 // This matches 16 permutations of 3005 // max(min(x, y), min(max(x, y), z)) 3006 def : GCNPat < 3007 (max (min_oneuse i16:$src0, i16:$src1), 3008 (min_oneuse (max_oneuse i16:$src0, i16:$src1), i16:$src2)), 3009 (med3Inst SRCMODS.NONE, VSrc_b16:$src0, SRCMODS.NONE, VSrc_b16:$src1, SRCMODS.NONE, VSrc_b16:$src2, DSTCLAMP.NONE) 3010>; 3011 3012 // This matches 16 permutations of 3013 // min(max(a, b), max(min(a, b), c)) 3014 def : GCNPat < 3015 (min (max_oneuse i16:$src0, i16:$src1), 3016 (max_oneuse (min_oneuse i16:$src0, i16:$src1), i16:$src2)), 3017 (med3Inst SRCMODS.NONE, VSrc_b16:$src0, SRCMODS.NONE, VSrc_b16:$src1, SRCMODS.NONE, VSrc_b16:$src2, DSTCLAMP.NONE) 3018>; 3019} 3020 3021def : FPMed3Pat<f32, V_MED3_F32_e64>; 3022 3023class 3024IntMinMaxPat<Instruction minmaxInst, SDPatternOperator min_or_max, 3025 SDPatternOperator max_or_min_oneuse> : AMDGPUPat < 3026 (DivergentBinFrag<min_or_max> (max_or_min_oneuse i32:$src0, i32:$src1), 3027 i32:$src2), 3028 (minmaxInst VSrc_b32:$src0, VSrc_b32:$src1, VSrc_b32:$src2) 3029>; 3030 3031class 3032FPMinMaxPat<Instruction minmaxInst, ValueType vt, SDPatternOperator min_or_max, 3033 SDPatternOperator max_or_min_oneuse> : GCNPat < 3034 (min_or_max (max_or_min_oneuse (VOP3Mods vt:$src0, i32:$src0_mods), 3035 (VOP3Mods vt:$src1, i32:$src1_mods)), 3036 (vt (VOP3Mods vt:$src2, i32:$src2_mods))), 3037 (minmaxInst $src0_mods, $src0, $src1_mods, $src1, $src2_mods, $src2, 3038 DSTCLAMP.NONE, DSTOMOD.NONE) 3039>; 3040 3041let OtherPredicates = [isGFX11Plus] in { 3042def : IntMinMaxPat<V_MAXMIN_I32_e64, smin, smax_oneuse>; 3043def : IntMinMaxPat<V_MINMAX_I32_e64, smax, smin_oneuse>; 3044def : IntMinMaxPat<V_MAXMIN_U32_e64, umin, umax_oneuse>; 3045def : IntMinMaxPat<V_MINMAX_U32_e64, umax, umin_oneuse>; 3046def : FPMinMaxPat<V_MINMAX_F32_e64, f32, fmaxnum_like, fminnum_like_oneuse>; 3047def : FPMinMaxPat<V_MAXMIN_F32_e64, f32, fminnum_like, fmaxnum_like_oneuse>; 3048def : FPMinMaxPat<V_MINMAX_F16_e64, f16, fmaxnum_like, fminnum_like_oneuse>; 3049def : FPMinMaxPat<V_MAXMIN_F16_e64, f16, fminnum_like, fmaxnum_like_oneuse>; 3050} 3051 3052let OtherPredicates = [isGFX9Plus] in { 3053def : FP16Med3Pat<f16, V_MED3_F16_e64>; 3054defm : Int16Med3Pat<V_MED3_I16_e64, smin, smax, smax_oneuse, smin_oneuse>; 3055defm : Int16Med3Pat<V_MED3_U16_e64, umin, umax, umax_oneuse, umin_oneuse>; 3056} // End Predicates = [isGFX9Plus] 3057 3058class AMDGPUGenericInstruction : GenericInstruction { 3059 let Namespace = "AMDGPU"; 3060} 3061 3062// Convert a wave address to a swizzled vector address (i.e. this is 3063// for copying the stack pointer to a vector address appropriate to 3064// use in the offset field of mubuf instructions). 3065def G_AMDGPU_WAVE_ADDRESS : AMDGPUGenericInstruction { 3066 let OutOperandList = (outs type0:$dst); 3067 let InOperandList = (ins type0:$src); 3068 let hasSideEffects = 0; 3069} 3070 3071// Returns -1 if the input is zero. 3072def G_AMDGPU_FFBH_U32 : AMDGPUGenericInstruction { 3073 let OutOperandList = (outs type0:$dst); 3074 let InOperandList = (ins type1:$src); 3075 let hasSideEffects = 0; 3076} 3077 3078// Returns -1 if the input is zero. 3079def G_AMDGPU_FFBL_B32 : AMDGPUGenericInstruction { 3080 let OutOperandList = (outs type0:$dst); 3081 let InOperandList = (ins type1:$src); 3082 let hasSideEffects = 0; 3083} 3084 3085def G_AMDGPU_RCP_IFLAG : AMDGPUGenericInstruction { 3086 let OutOperandList = (outs type0:$dst); 3087 let InOperandList = (ins type1:$src); 3088 let hasSideEffects = 0; 3089} 3090 3091class BufferLoadGenericInstruction : AMDGPUGenericInstruction { 3092 let OutOperandList = (outs type0:$dst); 3093 let InOperandList = (ins type1:$rsrc, type2:$vindex, type2:$voffset, 3094 type2:$soffset, untyped_imm_0:$offset, 3095 untyped_imm_0:$cachepolicy, untyped_imm_0:$idxen); 3096 let hasSideEffects = 0; 3097 let mayLoad = 1; 3098} 3099 3100class TBufferLoadGenericInstruction : AMDGPUGenericInstruction { 3101 let OutOperandList = (outs type0:$dst); 3102 let InOperandList = (ins type1:$rsrc, type2:$vindex, type2:$voffset, 3103 type2:$soffset, untyped_imm_0:$offset, untyped_imm_0:$format, 3104 untyped_imm_0:$cachepolicy, untyped_imm_0:$idxen); 3105 let hasSideEffects = 0; 3106 let mayLoad = 1; 3107} 3108 3109def G_AMDGPU_BUFFER_LOAD_UBYTE : BufferLoadGenericInstruction; 3110def G_AMDGPU_BUFFER_LOAD_SBYTE : BufferLoadGenericInstruction; 3111def G_AMDGPU_BUFFER_LOAD_USHORT : BufferLoadGenericInstruction; 3112def G_AMDGPU_BUFFER_LOAD_SSHORT : BufferLoadGenericInstruction; 3113def G_AMDGPU_BUFFER_LOAD : BufferLoadGenericInstruction; 3114def G_AMDGPU_BUFFER_LOAD_FORMAT : BufferLoadGenericInstruction; 3115def G_AMDGPU_BUFFER_LOAD_FORMAT_D16 : BufferLoadGenericInstruction; 3116def G_AMDGPU_TBUFFER_LOAD_FORMAT : TBufferLoadGenericInstruction; 3117def G_AMDGPU_TBUFFER_LOAD_FORMAT_D16 : TBufferLoadGenericInstruction; 3118 3119class BufferStoreGenericInstruction : AMDGPUGenericInstruction { 3120 let OutOperandList = (outs); 3121 let InOperandList = (ins type0:$vdata, type1:$rsrc, type2:$vindex, type2:$voffset, 3122 type2:$soffset, untyped_imm_0:$offset, 3123 untyped_imm_0:$cachepolicy, untyped_imm_0:$idxen); 3124 let hasSideEffects = 0; 3125 let mayStore = 1; 3126} 3127 3128class TBufferStoreGenericInstruction : AMDGPUGenericInstruction { 3129 let OutOperandList = (outs); 3130 let InOperandList = (ins type0:$vdata, type1:$rsrc, type2:$vindex, type2:$voffset, 3131 type2:$soffset, untyped_imm_0:$offset, 3132 untyped_imm_0:$format, 3133 untyped_imm_0:$cachepolicy, untyped_imm_0:$idxen); 3134 let hasSideEffects = 0; 3135 let mayStore = 1; 3136} 3137 3138def G_AMDGPU_BUFFER_STORE : BufferStoreGenericInstruction; 3139def G_AMDGPU_BUFFER_STORE_BYTE : BufferStoreGenericInstruction; 3140def G_AMDGPU_BUFFER_STORE_SHORT : BufferStoreGenericInstruction; 3141def G_AMDGPU_BUFFER_STORE_FORMAT : BufferStoreGenericInstruction; 3142def G_AMDGPU_BUFFER_STORE_FORMAT_D16 : BufferStoreGenericInstruction; 3143def G_AMDGPU_TBUFFER_STORE_FORMAT : TBufferStoreGenericInstruction; 3144def G_AMDGPU_TBUFFER_STORE_FORMAT_D16 : TBufferStoreGenericInstruction; 3145 3146def G_AMDGPU_FMIN_LEGACY : AMDGPUGenericInstruction { 3147 let OutOperandList = (outs type0:$dst); 3148 let InOperandList = (ins type0:$src0, type0:$src1); 3149 let hasSideEffects = 0; 3150} 3151 3152def G_AMDGPU_FMAX_LEGACY : AMDGPUGenericInstruction { 3153 let OutOperandList = (outs type0:$dst); 3154 let InOperandList = (ins type0:$src0, type0:$src1); 3155 let hasSideEffects = 0; 3156} 3157 3158foreach N = 0-3 in { 3159def G_AMDGPU_CVT_F32_UBYTE#N : AMDGPUGenericInstruction { 3160 let OutOperandList = (outs type0:$dst); 3161 let InOperandList = (ins type0:$src0); 3162 let hasSideEffects = 0; 3163} 3164} 3165 3166def G_AMDGPU_CVT_PK_I16_I32 : AMDGPUGenericInstruction { 3167 let OutOperandList = (outs type0:$dst); 3168 let InOperandList = (ins type0:$src0, type0:$src1); 3169 let hasSideEffects = 0; 3170} 3171 3172def G_AMDGPU_SMED3 : AMDGPUGenericInstruction { 3173 let OutOperandList = (outs type0:$dst); 3174 let InOperandList = (ins type0:$src0, type0:$src1, type0:$src2); 3175 let hasSideEffects = 0; 3176} 3177 3178def G_AMDGPU_UMED3 : AMDGPUGenericInstruction { 3179 let OutOperandList = (outs type0:$dst); 3180 let InOperandList = (ins type0:$src0, type0:$src1, type0:$src2); 3181 let hasSideEffects = 0; 3182} 3183 3184def G_AMDGPU_FMED3 : AMDGPUGenericInstruction { 3185 let OutOperandList = (outs type0:$dst); 3186 let InOperandList = (ins type0:$src0, type0:$src1, type0:$src2); 3187 let hasSideEffects = 0; 3188} 3189 3190def G_AMDGPU_CLAMP : AMDGPUGenericInstruction { 3191 let OutOperandList = (outs type0:$dst); 3192 let InOperandList = (ins type0:$src); 3193 let hasSideEffects = 0; 3194} 3195 3196// Integer multiply-add: arg0 * arg1 + arg2. 3197// 3198// arg0 and arg1 are 32-bit integers (interpreted as signed or unsigned), 3199// arg2 is a 64-bit integer. Result is a 64-bit integer and a 1-bit carry-out. 3200class G_AMDGPU_MAD_64_32 : AMDGPUGenericInstruction { 3201 let OutOperandList = (outs type0:$dst, type1:$carry_out); 3202 let InOperandList = (ins type2:$arg0, type2:$arg1, type0:$arg2); 3203 let hasSideEffects = 0; 3204} 3205 3206def G_AMDGPU_MAD_U64_U32 : G_AMDGPU_MAD_64_32; 3207def G_AMDGPU_MAD_I64_I32 : G_AMDGPU_MAD_64_32; 3208 3209// Atomic cmpxchg. $cmpval ad $newval are packed in a single vector 3210// operand Expects a MachineMemOperand in addition to explicit 3211// operands. 3212def G_AMDGPU_ATOMIC_CMPXCHG : AMDGPUGenericInstruction { 3213 let OutOperandList = (outs type0:$oldval); 3214 let InOperandList = (ins ptype1:$addr, type0:$cmpval_newval); 3215 let hasSideEffects = 0; 3216 let mayLoad = 1; 3217 let mayStore = 1; 3218} 3219 3220let Namespace = "AMDGPU" in { 3221def G_AMDGPU_ATOMIC_INC : G_ATOMICRMW_OP; 3222def G_AMDGPU_ATOMIC_DEC : G_ATOMICRMW_OP; 3223def G_AMDGPU_ATOMIC_FMIN : G_ATOMICRMW_OP; 3224def G_AMDGPU_ATOMIC_FMAX : G_ATOMICRMW_OP; 3225} 3226 3227class BufferAtomicGenericInstruction<bit NoRtn = 0> : AMDGPUGenericInstruction { 3228 let OutOperandList = !if(NoRtn, (outs), (outs type0:$dst)); 3229 let InOperandList = (ins type0:$vdata, type1:$rsrc, type2:$vindex, type2:$voffset, 3230 type2:$soffset, untyped_imm_0:$offset, 3231 untyped_imm_0:$cachepolicy, untyped_imm_0:$idxen); 3232 let hasSideEffects = 0; 3233 let mayLoad = 1; 3234 let mayStore = 1; 3235} 3236 3237def G_AMDGPU_BUFFER_ATOMIC_SWAP : BufferAtomicGenericInstruction; 3238def G_AMDGPU_BUFFER_ATOMIC_ADD : BufferAtomicGenericInstruction; 3239def G_AMDGPU_BUFFER_ATOMIC_SUB : BufferAtomicGenericInstruction; 3240def G_AMDGPU_BUFFER_ATOMIC_SMIN : BufferAtomicGenericInstruction; 3241def G_AMDGPU_BUFFER_ATOMIC_UMIN : BufferAtomicGenericInstruction; 3242def G_AMDGPU_BUFFER_ATOMIC_SMAX : BufferAtomicGenericInstruction; 3243def G_AMDGPU_BUFFER_ATOMIC_UMAX : BufferAtomicGenericInstruction; 3244def G_AMDGPU_BUFFER_ATOMIC_AND : BufferAtomicGenericInstruction; 3245def G_AMDGPU_BUFFER_ATOMIC_OR : BufferAtomicGenericInstruction; 3246def G_AMDGPU_BUFFER_ATOMIC_XOR : BufferAtomicGenericInstruction; 3247def G_AMDGPU_BUFFER_ATOMIC_INC : BufferAtomicGenericInstruction; 3248def G_AMDGPU_BUFFER_ATOMIC_DEC : BufferAtomicGenericInstruction; 3249def G_AMDGPU_BUFFER_ATOMIC_FADD : BufferAtomicGenericInstruction; 3250def G_AMDGPU_BUFFER_ATOMIC_FMIN : BufferAtomicGenericInstruction; 3251def G_AMDGPU_BUFFER_ATOMIC_FMAX : BufferAtomicGenericInstruction; 3252 3253def G_AMDGPU_BUFFER_ATOMIC_CMPSWAP : AMDGPUGenericInstruction { 3254 let OutOperandList = (outs type0:$dst); 3255 let InOperandList = (ins type0:$vdata, type0:$cmp, type1:$rsrc, type2:$vindex, 3256 type2:$voffset, type2:$soffset, untyped_imm_0:$offset, 3257 untyped_imm_0:$cachepolicy, untyped_imm_0:$idxen); 3258 let hasSideEffects = 0; 3259 let mayLoad = 1; 3260 let mayStore = 1; 3261} 3262 3263// Wrapper around llvm.amdgcn.s.buffer.load. This is mostly needed as 3264// a workaround for the intrinsic being defined as readnone, but 3265// really needs a memory operand. 3266def G_AMDGPU_S_BUFFER_LOAD : AMDGPUGenericInstruction { 3267 let OutOperandList = (outs type0:$dst); 3268 let InOperandList = (ins type1:$rsrc, type2:$offset, untyped_imm_0:$cachepolicy); 3269 let hasSideEffects = 0; 3270 let mayLoad = 1; 3271 let mayStore = 0; 3272} 3273 3274// This is equivalent to the G_INTRINSIC*, but the operands may have 3275// been legalized depending on the subtarget requirements. 3276def G_AMDGPU_INTRIN_IMAGE_LOAD : AMDGPUGenericInstruction { 3277 let OutOperandList = (outs type0:$dst); 3278 let InOperandList = (ins unknown:$intrin, variable_ops); 3279 let hasSideEffects = 0; 3280 let mayLoad = 1; 3281 3282 // FIXME: Use separate opcode for atomics. 3283 let mayStore = 1; 3284} 3285 3286def G_AMDGPU_INTRIN_IMAGE_LOAD_D16 : AMDGPUGenericInstruction { 3287 let OutOperandList = (outs type0:$dst); 3288 let InOperandList = (ins unknown:$intrin, variable_ops); 3289 let hasSideEffects = 0; 3290 let mayLoad = 1; 3291 3292 // FIXME: Use separate opcode for atomics. 3293 let mayStore = 1; 3294} 3295 3296// This is equivalent to the G_INTRINSIC*, but the operands may have 3297// been legalized depending on the subtarget requirements. 3298def G_AMDGPU_INTRIN_IMAGE_STORE : AMDGPUGenericInstruction { 3299 let OutOperandList = (outs); 3300 let InOperandList = (ins unknown:$intrin, variable_ops); 3301 let hasSideEffects = 0; 3302 let mayStore = 1; 3303} 3304 3305def G_AMDGPU_INTRIN_IMAGE_STORE_D16 : AMDGPUGenericInstruction { 3306 let OutOperandList = (outs); 3307 let InOperandList = (ins unknown:$intrin, variable_ops); 3308 let hasSideEffects = 0; 3309 let mayStore = 1; 3310} 3311 3312def G_AMDGPU_INTRIN_BVH_INTERSECT_RAY : AMDGPUGenericInstruction { 3313 let OutOperandList = (outs type0:$dst); 3314 let InOperandList = (ins unknown:$intrin, variable_ops); 3315 let hasSideEffects = 0; 3316 let mayLoad = 1; 3317 let mayStore = 0; 3318} 3319 3320// Generic instruction for SI_CALL, so we can select the register bank and insert a waterfall loop 3321// if necessary. 3322def G_SI_CALL : AMDGPUGenericInstruction { 3323 let OutOperandList = (outs SReg_64:$dst); 3324 let InOperandList = (ins type0:$src0, unknown:$callee); 3325 let Size = 4; 3326 let isCall = 1; 3327 let UseNamedOperandTable = 1; 3328 let SchedRW = [WriteBranch]; 3329 // TODO: Should really base this on the call target 3330 let isConvergent = 1; 3331} 3332 3333def G_FPTRUNC_ROUND_UPWARD : AMDGPUGenericInstruction { 3334 let OutOperandList = (outs type0:$vdst); 3335 let InOperandList = (ins type1:$src0); 3336 let hasSideEffects = 0; 3337} 3338 3339def G_FPTRUNC_ROUND_DOWNWARD : AMDGPUGenericInstruction { 3340 let OutOperandList = (outs type0:$vdst); 3341 let InOperandList = (ins type1:$src0); 3342 let hasSideEffects = 0; 3343} 3344