LLVM 24.0.0git
GCNDPPCombine.cpp
Go to the documentation of this file.
1//=======- GCNDPPCombine.cpp - optimization for DPP instructions ---==========//
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// The pass combines V_MOV_B32_dpp instruction with its VALU uses as a DPP src0
9// operand. If any of the use instruction cannot be combined with the mov the
10// whole sequence is reverted.
11//
12// $old = ...
13// $dpp_value = V_MOV_B32_dpp $old, $vgpr_to_be_read_from_other_lane,
14// dpp_controls..., $row_mask, $bank_mask, $bound_ctrl
15// $res = VALU $dpp_value [, src1]
16//
17// to
18//
19// $res = VALU_DPP $combined_old, $vgpr_to_be_read_from_other_lane, [src1,]
20// dpp_controls..., $row_mask, $bank_mask, $combined_bound_ctrl
21//
22// Combining rules :
23//
24// if $row_mask and $bank_mask are fully enabled (0xF) and
25// $bound_ctrl==DPP_BOUND_ZERO or $old==0
26// -> $combined_old = undef,
27// $combined_bound_ctrl = DPP_BOUND_ZERO
28//
29// if the VALU op is binary and
30// $bound_ctrl==DPP_BOUND_OFF and
31// $old==identity value (immediate) for the VALU op
32// -> $combined_old = src1,
33// $combined_bound_ctrl = DPP_BOUND_OFF
34//
35// Otherwise cancel.
36//
37// The mov_dpp instruction should reside in the same BB as all its uses
38//===----------------------------------------------------------------------===//
39
40#include "GCNDPPCombine.h"
41#include "AMDGPU.h"
42#include "GCNSubtarget.h"
44#include "llvm/ADT/Statistic.h"
47
48using namespace llvm;
49
50#define DEBUG_TYPE "gcn-dpp-combine"
51
52STATISTIC(NumDPPMovsCombined, "Number of DPP moves combined.");
53
54namespace {
55
56class GCNDPPCombine {
58 const SIInstrInfo *TII;
59 const GCNSubtarget *ST;
60
62
63 MachineOperand *getOldOpndValue(MachineOperand &OldOpnd) const;
64
65 MachineInstr *createDPPInst(MachineInstr &OrigMI, MachineInstr &MovMI,
66 RegSubRegPair CombOldVGPR,
67 MachineOperand *OldOpnd, bool CombBCZ,
68 bool IsShrinkable) const;
69
70 MachineInstr *createDPPInst(MachineInstr &OrigMI, MachineInstr &MovMI,
71 RegSubRegPair CombOldVGPR, bool CombBCZ,
72 bool IsShrinkable) const;
73
74 bool hasNoImmOrEqual(MachineInstr &MI, AMDGPU::OpName OpndName, int64_t Value,
75 int64_t Mask = -1) const;
76
77 bool combineDPPMov(MachineInstr &MI) const;
78
79 int getDPPOp(unsigned Op, bool IsShrinkable) const;
80 bool isShrinkable(MachineInstr &MI) const;
81
82public:
83 bool run(MachineFunction &MF);
84};
85
86class GCNDPPCombineLegacy : public MachineFunctionPass {
87public:
88 static char ID;
89
90 GCNDPPCombineLegacy() : MachineFunctionPass(ID) {}
91
92 bool runOnMachineFunction(MachineFunction &MF) override;
93
94 StringRef getPassName() const override { return "GCN DPP Combine"; }
95
96 void getAnalysisUsage(AnalysisUsage &AU) const override {
97 AU.setPreservesCFG();
99 }
100
101 MachineFunctionProperties getRequiredProperties() const override {
102 return MachineFunctionProperties().setIsSSA();
103 }
104};
105
106} // end anonymous namespace
107
108INITIALIZE_PASS(GCNDPPCombineLegacy, DEBUG_TYPE, "GCN DPP Combine", false,
109 false)
110
111char GCNDPPCombineLegacy::ID = 0;
112
113char &llvm::GCNDPPCombineLegacyID = GCNDPPCombineLegacy::ID;
114
116 return new GCNDPPCombineLegacy();
117}
118
119bool GCNDPPCombine::isShrinkable(MachineInstr &MI) const {
120 unsigned Op = MI.getOpcode();
121 if (!TII->isVOP3(Op)) {
122 return false;
123 }
124 if (!TII->hasVALU32BitEncoding(Op)) {
125 LLVM_DEBUG(dbgs() << " Inst hasn't e32 equivalent\n");
126 return false;
127 }
128 // Do not shrink True16 instructions pre-RA to avoid the restriction in
129 // register allocation from only being able to use 128 VGPRs
131 return false;
132 if (const auto *SDst = TII->getNamedOperand(MI, AMDGPU::OpName::sdst)) {
133 // Give up if there are any uses of the sdst in carry-out or VOPC.
134 // The shrunken form of the instruction would write it to vcc instead of to
135 // a virtual register. If we rewrote the uses the shrinking would be
136 // possible.
137 if (!MRI->use_nodbg_empty(SDst->getReg()))
138 return false;
139 }
140 // check if other than abs|neg modifiers are set (opsel for example)
141 const int64_t Mask = ~(SISrcMods::ABS | SISrcMods::NEG);
142 if (!hasNoImmOrEqual(MI, AMDGPU::OpName::src0_modifiers, 0, Mask) ||
143 !hasNoImmOrEqual(MI, AMDGPU::OpName::src1_modifiers, 0, Mask) ||
144 !hasNoImmOrEqual(MI, AMDGPU::OpName::clamp, 0) ||
145 !hasNoImmOrEqual(MI, AMDGPU::OpName::omod, 0) ||
146 !hasNoImmOrEqual(MI, AMDGPU::OpName::byte_sel, 0)) {
147 LLVM_DEBUG(dbgs() << " Inst has non-default modifiers\n");
148 return false;
149 }
150 return true;
151}
152
153int GCNDPPCombine::getDPPOp(unsigned Op, bool IsShrinkable) const {
154 int DPP32 = AMDGPU::getDPPOp32(Op);
155 if (IsShrinkable) {
156 assert(DPP32 == -1);
157 int E32 = AMDGPU::getVOPe32(Op);
158 DPP32 = (E32 == -1) ? -1 : AMDGPU::getDPPOp32(E32);
159 }
160 if (DPP32 != -1 && TII->pseudoToMCOpcode(DPP32) != -1)
161 return DPP32;
162 int DPP64 = -1;
163 if (ST->hasVOP3DPP())
164 DPP64 = AMDGPU::getDPPOp64(Op);
165 if (DPP64 != -1 && TII->pseudoToMCOpcode(DPP64) != -1)
166 return DPP64;
167 return -1;
168}
169
170// tracks the register operand definition and returns:
171// 1. immediate operand used to initialize the register if found
172// 2. nullptr if the register operand is undef
173// 3. the operand itself otherwise
174MachineOperand *GCNDPPCombine::getOldOpndValue(MachineOperand &OldOpnd) const {
175 auto *Def = getVRegSubRegDef(getRegSubRegPair(OldOpnd), *MRI);
176 if (!Def)
177 return nullptr;
178
179 switch(Def->getOpcode()) {
180 default: break;
181 case AMDGPU::IMPLICIT_DEF:
182 return nullptr;
183 case AMDGPU::COPY:
184 case AMDGPU::V_MOV_B32_e32:
185 case AMDGPU::V_MOV_B64_PSEUDO:
186 case AMDGPU::V_MOV_B64_e32:
187 case AMDGPU::V_MOV_B64_e64: {
188 auto &Op1 = Def->getOperand(1);
189 if (Op1.isImm())
190 return &Op1;
191 break;
192 }
193 }
194 return &OldOpnd;
195}
196
197MachineInstr *GCNDPPCombine::createDPPInst(MachineInstr &OrigMI,
198 MachineInstr &MovMI,
199 RegSubRegPair CombOldVGPR,
200 bool CombBCZ,
201 bool IsShrinkable) const {
202 assert(MovMI.getOpcode() == AMDGPU::V_MOV_B32_dpp ||
203 MovMI.getOpcode() == AMDGPU::V_MOV_B64_dpp ||
204 MovMI.getOpcode() == AMDGPU::V_MOV_B64_DPP_PSEUDO);
205
206 bool HasVOP3DPP = ST->hasVOP3DPP();
207 auto OrigOp = OrigMI.getOpcode();
208 if (ST->useRealTrue16Insts() && AMDGPU::isTrue16Inst(OrigOp)) {
210 dbgs() << " failed: Did not expect any 16-bit uses of dpp values\n");
211 return nullptr;
212 }
213 auto DPPOp = getDPPOp(OrigOp, IsShrinkable);
214 if (DPPOp == -1) {
215 LLVM_DEBUG(dbgs() << " failed: no DPP opcode\n");
216 return nullptr;
217 }
218
219 const int OldIdx = AMDGPU::getNamedOperandIdx(DPPOp, AMDGPU::OpName::old);
220 const int MovDstIdx =
221 AMDGPU::getNamedOperandIdx(MovMI.getOpcode(), AMDGPU::OpName::vdst);
222 if (OldIdx != -1 &&
223 TII->getOpSize(DPPOp, OldIdx) != TII->getOpSize(MovMI, MovDstIdx)) {
224 LLVM_DEBUG(dbgs() << " failed: old operand size differs from dst\n");
225 return nullptr;
226 }
227
228 int OrigOpE32 = AMDGPU::getVOPe32(OrigOp);
229 // Prior checks cover Mask with VOPC condition, but not on purpose
230 auto *RowMaskOpnd = TII->getNamedOperand(MovMI, AMDGPU::OpName::row_mask);
231 assert(RowMaskOpnd && RowMaskOpnd->isImm());
232 auto *BankMaskOpnd = TII->getNamedOperand(MovMI, AMDGPU::OpName::bank_mask);
233 assert(BankMaskOpnd && BankMaskOpnd->isImm());
234 const bool MaskAllLanes =
235 RowMaskOpnd->getImm() == 0xF && BankMaskOpnd->getImm() == 0xF;
236 (void)MaskAllLanes;
237 assert((MaskAllLanes ||
238 !(TII->isVOPC(DPPOp) || (TII->isVOP3(DPPOp) && OrigOpE32 != -1 &&
239 TII->isVOPC(OrigOpE32)))) &&
240 "VOPC cannot form DPP unless mask is full");
241
242 auto DPPInst = BuildMI(*OrigMI.getParent(), OrigMI,
243 OrigMI.getDebugLoc(), TII->get(DPPOp))
244 .setMIFlags(OrigMI.getFlags());
245
246 bool Fail = false;
247 do {
248 int NumOperands = 0;
249 if (auto *Dst = TII->getNamedOperand(OrigMI, AMDGPU::OpName::vdst)) {
250 DPPInst.add(*Dst);
251 ++NumOperands;
252 }
253 if (auto *SDst = TII->getNamedOperand(OrigMI, AMDGPU::OpName::sdst)) {
254 if (AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::sdst)) {
255 DPPInst.add(*SDst);
256 ++NumOperands;
257 }
258 // If we shrunk a 64bit vop3b to 32bits, just ignore the sdst
259 }
260
261 if (OldIdx != -1) {
262 assert(OldIdx == NumOperands);
264 CombOldVGPR,
265 *MRI->getRegClass(
266 TII->getNamedOperand(MovMI, AMDGPU::OpName::vdst)->getReg()),
267 *MRI));
268 auto *Def = getVRegSubRegDef(CombOldVGPR, *MRI);
269 DPPInst.addReg(CombOldVGPR.Reg, getUndefRegState(!Def),
270 CombOldVGPR.SubReg);
271 ++NumOperands;
272 } else if (TII->isVOPC(DPPOp) || (TII->isVOP3(DPPOp) && OrigOpE32 != -1 &&
273 TII->isVOPC(OrigOpE32))) {
274 // VOPC DPP and VOPC promoted to VOP3 DPP do not have an old operand
275 // because they write to SGPRs not VGPRs
276 } else {
277 // TODO: this discards MAC/FMA instructions for now, let's add it later
278 LLVM_DEBUG(dbgs() << " failed: no old operand in DPP instruction,"
279 " TBD\n");
280 Fail = true;
281 break;
282 }
283
284 auto *Mod0 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src0_modifiers);
285 if (Mod0) {
286 assert(NumOperands == AMDGPU::getNamedOperandIdx(DPPOp,
287 AMDGPU::OpName::src0_modifiers));
288 assert(HasVOP3DPP ||
289 (0LL == (Mod0->getImm() & ~(SISrcMods::ABS | SISrcMods::NEG))));
290 DPPInst.addImm(Mod0->getImm());
291 ++NumOperands;
292 } else if (AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::src0_modifiers)) {
293 DPPInst.addImm(0);
294 ++NumOperands;
295 }
296 auto *Src0 = TII->getNamedOperand(MovMI, AMDGPU::OpName::src0);
297 assert(Src0);
298 [[maybe_unused]] int Src0Idx = NumOperands;
299
300 DPPInst.add(*Src0);
301 DPPInst->getOperand(NumOperands).setIsKill(false);
302 ++NumOperands;
303
304 auto *Mod1 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src1_modifiers);
305 if (Mod1) {
306 assert(NumOperands == AMDGPU::getNamedOperandIdx(DPPOp,
307 AMDGPU::OpName::src1_modifiers));
308 assert(HasVOP3DPP ||
309 (0LL == (Mod1->getImm() & ~(SISrcMods::ABS | SISrcMods::NEG))));
310 DPPInst.addImm(Mod1->getImm());
311 ++NumOperands;
312 } else if (AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::src1_modifiers)) {
313 DPPInst.addImm(0);
314 ++NumOperands;
315 }
316 auto *Src1 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src1);
317 if (Src1) {
318 assert(AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::src1) &&
319 "dpp version of instruction missing src1");
320
321 DPPInst.add(*Src1);
322 ++NumOperands;
323 }
324
325 auto *Mod2 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src2_modifiers);
326 if (Mod2) {
327 assert(NumOperands ==
328 AMDGPU::getNamedOperandIdx(DPPOp, AMDGPU::OpName::src2_modifiers));
329 assert(HasVOP3DPP ||
330 (0LL == (Mod2->getImm() & ~(SISrcMods::ABS | SISrcMods::NEG))));
331 DPPInst.addImm(Mod2->getImm());
332 ++NumOperands;
333 }
334 auto *Src2 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src2);
335 if (Src2) {
336 if (!AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::src2)) {
337 LLVM_DEBUG(dbgs() << " failed: dpp does not have src2\n");
338 Fail = true;
339 break;
340 }
341 DPPInst.add(*Src2);
342 ++NumOperands;
343 }
344
345 if (HasVOP3DPP) {
346 auto *ClampOpr = TII->getNamedOperand(OrigMI, AMDGPU::OpName::clamp);
347 if (ClampOpr && AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::clamp)) {
348 DPPInst.addImm(ClampOpr->getImm());
349 }
350 auto *VdstInOpr = TII->getNamedOperand(OrigMI, AMDGPU::OpName::vdst_in);
351 if (VdstInOpr &&
352 AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::vdst_in)) {
353 DPPInst.add(*VdstInOpr);
354 }
355 auto *OmodOpr = TII->getNamedOperand(OrigMI, AMDGPU::OpName::omod);
356 if (OmodOpr && AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::omod)) {
357 DPPInst.addImm(OmodOpr->getImm());
358 }
359 // Validate OP_SEL has to be set to all 0 and OP_SEL_HI has to be set to
360 // all 1.
361 if (TII->getNamedOperand(OrigMI, AMDGPU::OpName::op_sel)) {
362 int64_t OpSel = 0;
363 OpSel |= (Mod0 ? (!!(Mod0->getImm() & SISrcMods::OP_SEL_0) << 0) : 0);
364 OpSel |= (Mod1 ? (!!(Mod1->getImm() & SISrcMods::OP_SEL_0) << 1) : 0);
365 OpSel |= (Mod2 ? (!!(Mod2->getImm() & SISrcMods::OP_SEL_0) << 2) : 0);
366 if (Mod0 && TII->isVOP3(OrigMI) && !TII->isVOP3P(OrigMI))
367 OpSel |= !!(Mod0->getImm() & SISrcMods::DST_OP_SEL) << 3;
368
369 if (OpSel != 0) {
370 LLVM_DEBUG(dbgs() << " failed: op_sel must be zero\n");
371 Fail = true;
372 break;
373 }
374 if (AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::op_sel))
375 DPPInst.addImm(OpSel);
376 }
377 if (TII->getNamedOperand(OrigMI, AMDGPU::OpName::op_sel_hi)) {
378 int64_t OpSelHi = 0;
379 OpSelHi |= (Mod0 ? (!!(Mod0->getImm() & SISrcMods::OP_SEL_1) << 0) : 0);
380 OpSelHi |= (Mod1 ? (!!(Mod1->getImm() & SISrcMods::OP_SEL_1) << 1) : 0);
381 OpSelHi |= (Mod2 ? (!!(Mod2->getImm() & SISrcMods::OP_SEL_1) << 2) : 0);
382
383 // Only vop3p has op_sel_hi, and all vop3p have 3 operands, so check
384 // the bitmask for 3 op_sel_hi bits set
385 assert(Src2 && "Expected vop3p with 3 operands");
386 if (OpSelHi != 7) {
387 LLVM_DEBUG(dbgs() << " failed: op_sel_hi must be all set to one\n");
388 Fail = true;
389 break;
390 }
391 if (AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::op_sel_hi))
392 DPPInst.addImm(OpSelHi);
393 }
394 auto *NegOpr = TII->getNamedOperand(OrigMI, AMDGPU::OpName::neg_lo);
395 if (NegOpr && AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::neg_lo)) {
396 DPPInst.addImm(NegOpr->getImm());
397 }
398 auto *NegHiOpr = TII->getNamedOperand(OrigMI, AMDGPU::OpName::neg_hi);
399 if (NegHiOpr && AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::neg_hi)) {
400 DPPInst.addImm(NegHiOpr->getImm());
401 }
402 auto *ByteSelOpr = TII->getNamedOperand(OrigMI, AMDGPU::OpName::byte_sel);
403 if (ByteSelOpr &&
404 AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::byte_sel)) {
405 DPPInst.addImm(ByteSelOpr->getImm());
406 }
407 if (MachineOperand *BitOp3 =
408 TII->getNamedOperand(OrigMI, AMDGPU::OpName::bitop3)) {
409 assert(AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::bitop3));
410 DPPInst.add(*BitOp3);
411 }
412 }
413 DPPInst.add(*TII->getNamedOperand(MovMI, AMDGPU::OpName::dpp_ctrl));
414 DPPInst.add(*TII->getNamedOperand(MovMI, AMDGPU::OpName::row_mask));
415 DPPInst.add(*TII->getNamedOperand(MovMI, AMDGPU::OpName::bank_mask));
416 DPPInst.addImm(CombBCZ ? 1 : 0);
417
418 constexpr AMDGPU::OpName Srcs[] = {
419 AMDGPU::OpName::src0, AMDGPU::OpName::src1, AMDGPU::OpName::src2};
420
421 // FIXME: isOperandLegal expects to operate on an completely built
422 // instruction. We should have better legality APIs to check if the
423 // candidate operands will be legal without building the instruction first.
424 for (auto [I, OpName] : enumerate(Srcs)) {
425 int OpIdx = AMDGPU::getNamedOperandIdx(DPPOp, OpName);
426 if (OpIdx == -1)
427 break;
428
429 if (!TII->isOperandLegal(*DPPInst, OpIdx)) {
430 LLVM_DEBUG(dbgs() << " failed: src" << I << " operand is illegal\n");
431 Fail = true;
432 break;
433 }
434 }
435 } while (false);
436
437 if (Fail) {
438 DPPInst.getInstr()->eraseFromParent();
439 return nullptr;
440 }
441 LLVM_DEBUG(dbgs() << " combined: " << *DPPInst.getInstr());
442 return DPPInst.getInstr();
443}
444
445static bool isIdentityValue(unsigned OrigMIOp, MachineOperand *OldOpnd) {
446 assert(OldOpnd->isImm());
447 switch (OrigMIOp) {
448 default: break;
449 case AMDGPU::V_ADD_U32_e32:
450 case AMDGPU::V_ADD_U32_e64:
451 case AMDGPU::V_ADD_CO_U32_e32:
452 case AMDGPU::V_ADD_CO_U32_e64:
453 case AMDGPU::V_OR_B32_e32:
454 case AMDGPU::V_OR_B32_e64:
455 case AMDGPU::V_SUBREV_U32_e32:
456 case AMDGPU::V_SUBREV_U32_e64:
457 case AMDGPU::V_SUBREV_CO_U32_e32:
458 case AMDGPU::V_SUBREV_CO_U32_e64:
459 case AMDGPU::V_MAX_U32_e32:
460 case AMDGPU::V_MAX_U32_e64:
461 case AMDGPU::V_XOR_B32_e32:
462 case AMDGPU::V_XOR_B32_e64:
463 if (OldOpnd->getImm() == 0)
464 return true;
465 break;
466 case AMDGPU::V_AND_B32_e32:
467 case AMDGPU::V_AND_B32_e64:
468 case AMDGPU::V_MIN_U32_e32:
469 case AMDGPU::V_MIN_U32_e64:
470 if (static_cast<uint32_t>(OldOpnd->getImm()) ==
471 std::numeric_limits<uint32_t>::max())
472 return true;
473 break;
474 case AMDGPU::V_MIN_I32_e32:
475 case AMDGPU::V_MIN_I32_e64:
476 if (static_cast<int32_t>(OldOpnd->getImm()) ==
477 std::numeric_limits<int32_t>::max())
478 return true;
479 break;
480 case AMDGPU::V_MAX_I32_e32:
481 case AMDGPU::V_MAX_I32_e64:
482 if (static_cast<int32_t>(OldOpnd->getImm()) ==
483 std::numeric_limits<int32_t>::min())
484 return true;
485 break;
486 case AMDGPU::V_MUL_I32_I24_e32:
487 case AMDGPU::V_MUL_I32_I24_e64:
488 case AMDGPU::V_MUL_U32_U24_e32:
489 case AMDGPU::V_MUL_U32_U24_e64:
490 if (OldOpnd->getImm() == 1)
491 return true;
492 break;
493 case AMDGPU::V_MIN_F32_e32:
494 case AMDGPU::V_MIN_F32_e64:
495 if (static_cast<uint32_t>(OldOpnd->getImm()) == /*+inf=*/0x7F800000)
496 return true;
497 break;
498 case AMDGPU::V_MAX_F32_e32:
499 case AMDGPU::V_MAX_F32_e64:
500 if (static_cast<uint32_t>(OldOpnd->getImm()) == /*-inf=*/0xFF800000)
501 return true;
502 break;
503 case AMDGPU::V_MIN_F64_e64:
504 case AMDGPU::V_MIN_NUM_F64_e64:
505 if (static_cast<uint64_t>(OldOpnd->getImm()) == /*+inf=*/0x7FF0000000000000)
506 return true;
507 break;
508 case AMDGPU::V_MAX_F64_e64:
509 case AMDGPU::V_MAX_NUM_F64_e64:
510 if (static_cast<uint64_t>(OldOpnd->getImm()) == /*-inf=*/0xFFF0000000000000)
511 return true;
512 break;
513 case AMDGPU::V_MIN_F16_e32:
514 case AMDGPU::V_MIN_F16_e64:
515 case AMDGPU::V_MIN_F16_t16_e32:
516 case AMDGPU::V_MIN_F16_t16_e64:
517 case AMDGPU::V_MIN_F16_fake16_e32:
518 case AMDGPU::V_MIN_F16_fake16_e64:
519 if (static_cast<uint16_t>(OldOpnd->getImm()) == /*+inf=*/0x7C00)
520 return true;
521 break;
522 case AMDGPU::V_MAX_F16_e32:
523 case AMDGPU::V_MAX_F16_e64:
524 case AMDGPU::V_MAX_F16_t16_e32:
525 case AMDGPU::V_MAX_F16_t16_e64:
526 case AMDGPU::V_MAX_F16_fake16_e32:
527 case AMDGPU::V_MAX_F16_fake16_e64:
528 if (static_cast<uint16_t>(OldOpnd->getImm()) == /*-inf=*/0xFC00)
529 return true;
530 break;
531 }
532 return false;
533}
534
535MachineInstr *GCNDPPCombine::createDPPInst(
536 MachineInstr &OrigMI, MachineInstr &MovMI, RegSubRegPair CombOldVGPR,
537 MachineOperand *OldOpndValue, bool CombBCZ, bool IsShrinkable) const {
538 assert(CombOldVGPR.Reg);
539 if (!CombBCZ && OldOpndValue && OldOpndValue->isImm()) {
540 auto *Src1 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src1);
541 if (!Src1 || !Src1->isReg()) {
542 LLVM_DEBUG(dbgs() << " failed: no src1 or it isn't a register\n");
543 return nullptr;
544 }
545 if (!isIdentityValue(OrigMI.getOpcode(), OldOpndValue)) {
546 LLVM_DEBUG(dbgs() << " failed: old immediate isn't an identity\n");
547 return nullptr;
548 }
549 CombOldVGPR = getRegSubRegPair(*Src1);
550 auto *MovDst = TII->getNamedOperand(MovMI, AMDGPU::OpName::vdst);
551 const TargetRegisterClass *RC = MRI->getRegClass(MovDst->getReg());
552 if (!isOfRegClass(CombOldVGPR, *RC, *MRI)) {
553 LLVM_DEBUG(dbgs() << " failed: src1 has wrong register class\n");
554 return nullptr;
555 }
556 }
557 return createDPPInst(OrigMI, MovMI, CombOldVGPR, CombBCZ, IsShrinkable);
558}
559
560// returns true if MI doesn't have OpndName immediate operand or the
561// operand has Value
562bool GCNDPPCombine::hasNoImmOrEqual(MachineInstr &MI, AMDGPU::OpName OpndName,
563 int64_t Value, int64_t Mask) const {
564 auto *Imm = TII->getNamedOperand(MI, OpndName);
565 if (!Imm)
566 return true;
567
568 assert(Imm->isImm());
569 return (Imm->getImm() & Mask) == Value;
570}
571
572bool GCNDPPCombine::combineDPPMov(MachineInstr &MovMI) const {
573 assert(MovMI.getOpcode() == AMDGPU::V_MOV_B32_dpp ||
574 MovMI.getOpcode() == AMDGPU::V_MOV_B64_dpp ||
575 MovMI.getOpcode() == AMDGPU::V_MOV_B64_DPP_PSEUDO);
576 LLVM_DEBUG(dbgs() << "\nDPP combine: " << MovMI);
577
578 auto *DstOpnd = TII->getNamedOperand(MovMI, AMDGPU::OpName::vdst);
579 assert(DstOpnd && DstOpnd->isReg());
580 auto DPPMovReg = DstOpnd->getReg();
581 if (DPPMovReg.isPhysical()) {
582 LLVM_DEBUG(dbgs() << " failed: dpp move writes physreg\n");
583 return false;
584 }
585 if (execMayBeModifiedBeforeAnyUse(*MRI, DPPMovReg, MovMI)) {
586 LLVM_DEBUG(dbgs() << " failed: EXEC mask should remain the same"
587 " for all uses\n");
588 return false;
589 }
590
591 auto *DppCtrl = TII->getNamedOperand(MovMI, AMDGPU::OpName::dpp_ctrl);
592 assert(DppCtrl && DppCtrl->isImm());
593 unsigned DppCtrlVal = DppCtrl->getImm();
594 if ((MovMI.getOpcode() == AMDGPU::V_MOV_B64_DPP_PSEUDO ||
595 MovMI.getOpcode() == AMDGPU::V_MOV_B64_dpp)) {
596 if (!ST->hasFeature(AMDGPU::FeatureDPALU_DPP)) {
597 LLVM_DEBUG(dbgs() << " failed: 64 bit dpp move is unsupported\n");
598 // Split it.
599 return false;
600 }
601 if (!AMDGPU::isLegalDPALU_DPPControl(*ST, DppCtrlVal)) {
602 LLVM_DEBUG(dbgs() << " failed: 64 bit dpp move uses unsupported"
603 " control value\n");
604 // Let it split, then control may become legal.
605 return false;
606 }
607 }
608
609 auto *RowMaskOpnd = TII->getNamedOperand(MovMI, AMDGPU::OpName::row_mask);
610 assert(RowMaskOpnd && RowMaskOpnd->isImm());
611 auto *BankMaskOpnd = TII->getNamedOperand(MovMI, AMDGPU::OpName::bank_mask);
612 assert(BankMaskOpnd && BankMaskOpnd->isImm());
613 const bool MaskAllLanes = RowMaskOpnd->getImm() == 0xF &&
614 BankMaskOpnd->getImm() == 0xF;
615
616 auto *BCZOpnd = TII->getNamedOperand(MovMI, AMDGPU::OpName::bound_ctrl);
617 assert(BCZOpnd && BCZOpnd->isImm());
618 bool BoundCtrlZero = BCZOpnd->getImm();
619
620 auto *OldOpnd = TII->getNamedOperand(MovMI, AMDGPU::OpName::old);
621 auto *SrcOpnd = TII->getNamedOperand(MovMI, AMDGPU::OpName::src0);
622 assert(OldOpnd && OldOpnd->isReg());
623 assert(SrcOpnd && SrcOpnd->isReg());
624 if (OldOpnd->getReg().isPhysical() || SrcOpnd->getReg().isPhysical()) {
625 LLVM_DEBUG(dbgs() << " failed: dpp move reads physreg\n");
626 return false;
627 }
628
629 auto * const OldOpndValue = getOldOpndValue(*OldOpnd);
630 // OldOpndValue is either undef (IMPLICIT_DEF) or immediate or something else
631 // We could use: assert(!OldOpndValue || OldOpndValue->isImm())
632 // but the third option is used to distinguish undef from non-immediate
633 // to reuse IMPLICIT_DEF instruction later
634 assert(!OldOpndValue || OldOpndValue->isImm() || OldOpndValue == OldOpnd);
635
636 bool CombBCZ = false;
637
638 if (MaskAllLanes && BoundCtrlZero) { // [1]
639 CombBCZ = true;
640 } else {
641 if (!OldOpndValue || !OldOpndValue->isImm()) {
642 LLVM_DEBUG(dbgs() << " failed: the DPP mov isn't combinable\n");
643 return false;
644 }
645
646 if (OldOpndValue->getImm() == 0) {
647 if (MaskAllLanes) {
648 assert(!BoundCtrlZero); // by check [1]
649 CombBCZ = true;
650 }
651 } else if (BoundCtrlZero) {
652 assert(!MaskAllLanes); // by check [1]
653 LLVM_DEBUG(dbgs() <<
654 " failed: old!=0 and bctrl:0 and not all lanes isn't combinable\n");
655 return false;
656 }
657 }
658
659 LLVM_DEBUG(dbgs() << " old=";
660 if (!OldOpndValue)
661 dbgs() << "undef";
662 else
663 dbgs() << *OldOpndValue;
664 dbgs() << ", bound_ctrl=" << CombBCZ << '\n');
665
666 SmallVector<MachineInstr*, 4> OrigMIs, DPPMIs;
667 DenseMap<MachineInstr*, SmallVector<unsigned, 4>> RegSeqWithOpNos;
668 auto CombOldVGPR = getRegSubRegPair(*OldOpnd);
669 // try to reuse previous old reg if its undefined (IMPLICIT_DEF)
670 if (CombBCZ && OldOpndValue) { // CombOldVGPR should be undef
671 const TargetRegisterClass *RC = MRI->getRegClass(DPPMovReg);
672 CombOldVGPR = RegSubRegPair(
673 MRI->createVirtualRegister(RC));
674 auto UndefInst = BuildMI(*MovMI.getParent(), MovMI, MovMI.getDebugLoc(),
675 TII->get(AMDGPU::IMPLICIT_DEF), CombOldVGPR.Reg);
676 DPPMIs.push_back(UndefInst.getInstr());
677 }
678
679 OrigMIs.push_back(&MovMI);
680 bool Rollback = true;
683
684 while (!Uses.empty()) {
685 MachineOperand *Use = Uses.pop_back_val();
686 Rollback = true;
687
688 auto &OrigMI = *Use->getParent();
689 LLVM_DEBUG(dbgs() << " try: " << OrigMI);
690
691 auto OrigOp = OrigMI.getOpcode();
692 assert((TII->get(OrigOp).getSize() != 4 || !AMDGPU::isTrue16Inst(OrigOp)) &&
693 "There should not be e32 True16 instructions pre-RA");
694 if (OrigOp == AMDGPU::REG_SEQUENCE) {
695 Register FwdReg = OrigMI.getOperand(0).getReg();
696 unsigned FwdSubReg = 0;
697
698 if (execMayBeModifiedBeforeAnyUse(*MRI, FwdReg, OrigMI)) {
699 LLVM_DEBUG(dbgs() << " failed: EXEC mask should remain the same"
700 " for all uses\n");
701 break;
702 }
703
704 unsigned OpNo, E = OrigMI.getNumOperands();
705 for (OpNo = 1; OpNo < E; OpNo += 2) {
706 if (OrigMI.getOperand(OpNo).getReg() == DPPMovReg) {
707 FwdSubReg = OrigMI.getOperand(OpNo + 1).getImm();
708 break;
709 }
710 }
711
712 if (!FwdSubReg)
713 break;
714
715 for (auto &Op : MRI->use_nodbg_operands(FwdReg)) {
716 if (Op.getSubReg() == FwdSubReg)
717 Uses.push_back(&Op);
718 }
719 RegSeqWithOpNos[&OrigMI].push_back(OpNo);
720 continue;
721 }
722
723 bool IsShrinkable = isShrinkable(OrigMI);
724 if (!(IsShrinkable ||
725 ((TII->isVOP3P(OrigOp) || TII->isVOPC(OrigOp) ||
726 TII->isVOP3(OrigOp)) &&
727 ST->hasVOP3DPP()) ||
728 TII->isVOP1(OrigOp) || TII->isVOP2(OrigOp))) {
729 LLVM_DEBUG(dbgs() << " failed: not VOP1/2/3/3P/C\n");
730 break;
731 }
732 if (OrigMI.modifiesRegister(AMDGPU::EXEC, ST->getRegisterInfo())) {
733 LLVM_DEBUG(dbgs() << " failed: can't combine v_cmpx\n");
734 break;
735 }
736
737 auto *Src0 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src0);
738 auto *Src1 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src1);
739 if (Use != Src0 && !(Use == Src1 && OrigMI.isCommutable())) { // [1]
740 LLVM_DEBUG(dbgs() << " failed: no suitable operands\n");
741 break;
742 }
743
744 auto *Src2 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src2);
745 assert(Src0 && "Src1 without Src0?");
746 if ((Use == Src0 && ((Src1 && Src1->isIdenticalTo(*Src0)) ||
747 (Src2 && Src2->isIdenticalTo(*Src0)))) ||
748 (Use == Src1 && (Src1->isIdenticalTo(*Src0) ||
749 (Src2 && Src2->isIdenticalTo(*Src1))))) {
751 dbgs()
752 << " " << OrigMI
753 << " failed: DPP register is used more than once per instruction\n");
754 break;
755 }
756
757 // We have to be careful to prevent trying to fold into the first source
758 // operand of instructions that apply DPP to the second source operand.
759 // This could be directly, or when folding into an instruction that will
760 // get commuted into one.
761 int FoldedOp =
762 (Use == Src0) ? static_cast<int>(OrigOp) : TII->commuteOpcode(OrigOp);
763 if (FoldedOp < 0 || TII->isSrc1DPPRevOpcode(*ST, FoldedOp)) {
765 dbgs() << " failed: Use operand cannot have DPP applied to it\n");
766 break;
767 }
768
769 // Without DPALU DPP there are no 64-bit DPP encodings. The 64-bit move is
770 // rejected above, but a 32-bit move folded into a source of a 64-bit
771 // instruction reaches here, so the operands have to be checked too.
772 if (!ST->hasFeature(AMDGPU::FeatureDPALU_DPP) &&
774 AMDGPU::hasAny64BitVGPROperands(TII->get(OrigOp), *TII, *ST))) {
775 LLVM_DEBUG(dbgs() << " " << OrigMI
776 << " failed: DPP ALU DPP is not supported\n");
777 break;
778 }
779
780 if (!AMDGPU::isLegalDPALU_DPPControl(*ST, DppCtrlVal) &&
781 AMDGPU::isDPALU_DPP(TII->get(OrigOp), *TII, *ST)) {
782 LLVM_DEBUG(dbgs() << " " << OrigMI
783 << " failed: not valid 64-bit DPP control value\n");
784 break;
785 }
786
787 LLVM_DEBUG(dbgs() << " combining: " << OrigMI);
788 if (Use == Src0) {
789 if (auto *DPPInst = createDPPInst(OrigMI, MovMI, CombOldVGPR,
790 OldOpndValue, CombBCZ, IsShrinkable)) {
791 DPPMIs.push_back(DPPInst);
792 Rollback = false;
793 }
794 } else {
795 assert(Use == Src1 && OrigMI.isCommutable()); // by check [1]
796 auto *BB = OrigMI.getParent();
797 auto *NewMI = BB->getParent()->CloneMachineInstr(&OrigMI);
798 BB->insert(OrigMI, NewMI);
799 if (TII->commuteInstruction(*NewMI)) {
800 LLVM_DEBUG(dbgs() << " commuted: " << *NewMI);
801 if (auto *DPPInst =
802 createDPPInst(*NewMI, MovMI, CombOldVGPR, OldOpndValue, CombBCZ,
803 IsShrinkable)) {
804 DPPMIs.push_back(DPPInst);
805 Rollback = false;
806 }
807 } else
808 LLVM_DEBUG(dbgs() << " failed: cannot be commuted\n");
809 NewMI->eraseFromParent();
810 }
811 if (Rollback)
812 break;
813 OrigMIs.push_back(&OrigMI);
814 }
815
816 Rollback |= !Uses.empty();
817
818 for (auto *MI : *(Rollback? &DPPMIs : &OrigMIs))
819 MI->eraseFromParent();
820
821 if (!Rollback) {
822 for (auto &S : RegSeqWithOpNos) {
823 if (MRI->use_nodbg_empty(S.first->getOperand(0).getReg())) {
824 S.first->eraseFromParent();
825 continue;
826 }
827 while (!S.second.empty())
828 S.first->getOperand(S.second.pop_back_val()).setIsUndef();
829 }
830 }
831
832 return !Rollback;
833}
834
835bool GCNDPPCombineLegacy::runOnMachineFunction(MachineFunction &MF) {
836 if (skipFunction(MF.getFunction()))
837 return false;
838
839 return GCNDPPCombine().run(MF);
840}
841
842bool GCNDPPCombine::run(MachineFunction &MF) {
843 ST = &MF.getSubtarget<GCNSubtarget>();
844 if (!ST->hasDPP())
845 return false;
846
847 MRI = &MF.getRegInfo();
848 TII = ST->getInstrInfo();
849
850 bool Changed = false;
851 for (auto &MBB : MF) {
852 for (MachineInstr &MI : llvm::make_early_inc_range(llvm::reverse(MBB))) {
853 if (MI.getOpcode() == AMDGPU::V_MOV_B32_dpp && combineDPPMov(MI)) {
854 Changed = true;
855 ++NumDPPMovsCombined;
856 } else if (MI.getOpcode() == AMDGPU::V_MOV_B64_DPP_PSEUDO ||
857 MI.getOpcode() == AMDGPU::V_MOV_B64_dpp) {
858 if (ST->hasDPALU_DPP() && combineDPPMov(MI)) {
859 Changed = true;
860 ++NumDPPMovsCombined;
861 } else {
862 auto Split = TII->expandMovDPP64(MI);
863 for (auto *M : {Split.first, Split.second}) {
864 if (M && combineDPPMov(*M))
865 ++NumDPPMovsCombined;
866 }
867 Changed = true;
868 }
869 }
870 }
871 }
872 return Changed;
873}
874
877 MFPropsModifier _(*this, MF);
878
879 if (MF.getFunction().hasOptNone())
880 return PreservedAnalyses::all();
881
882 bool Changed = GCNDPPCombine().run(MF);
883 if (!Changed)
884 return PreservedAnalyses::all();
885
887 PA.preserveSet<CFGAnalyses>();
888 return PA;
889}
#define Fail
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned Imm
unsigned uint64_t
Provides AMDGPU specific target descriptions.
MachineBasicBlock & MBB
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static bool isIdentityValue(unsigned OrigMIOp, MachineOperand *OldOpnd)
AMD GCN specific subclass of TargetSubtarget.
#define DEBUG_TYPE
const HexagonInstrInfo * TII
#define _
IRTranslator LLVM IR MI
#define I(x, y, z)
Definition MD5.cpp:57
TargetInstrInfo::RegSubRegPair RegSubRegPair
Promote Memory to Register
Definition Mem2Reg.cpp:110
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition PassSupport.h:56
Remove Loads Into Fake Uses
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Definition Statistic.h:171
#define LLVM_DEBUG(...)
Definition Debug.h:119
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Definition Pass.cpp:278
Represents analyses that only rely on functions' control flow.
Definition Analysis.h:73
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:314
bool hasOptNone() const
Do not optimize this function (-O0).
Definition Function.h:686
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MAM)
const SIInstrInfo * getInstrInfo() const override
const SIRegisterInfo * getRegisterInfo() const override
bool useRealTrue16Insts() const
Return true if real (non-fake) variants of True16 instructions using 16-bit registers should be code-...
bool hasVOP3DPP() const
unsigned getSize(const MachineInstr &MI) const
An RAII based helper class to modify MachineFunctionProperties when running pass.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
void insert(iterator MBBI, MachineBasicBlock *MBB)
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineBasicBlock * getParent() const
unsigned getNumOperands() const
Retuns the total number of operands.
bool modifiesRegister(Register Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr modifies (fully define or partially define) the specified register.
bool isCommutable(QueryType Type=IgnoreBundle) const
Return true if this may be a 2- or 3-address instruction (of the form "X = op Y, Z,...
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
const MachineOperand & getOperand(unsigned i) const
uint32_t getFlags() const
Return the MI flags bitvector.
MachineOperand class - Representation of each machine instruction operand.
int64_t getImm() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
iterator_range< use_nodbg_iterator > use_nodbg_operands(Register Reg) const
bool use_nodbg_empty(Register RegNo) const
use_nodbg_empty - Return true if there are no non-Debug instructions using the specified register.
LLVM_ABI Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
Definition Register.h:83
LLVM Value Representation.
Definition Value.h:75
Changed
LLVM_READONLY int32_t getDPPOp32(uint32_t Opcode)
LLVM_READNONE bool isLegalDPALU_DPPControl(const MCSubtargetInfo &ST, unsigned DC)
LLVM_READONLY bool hasNamedOperand(uint64_t Opcode, OpName NamedIdx)
bool isDPALU_DPP32BitOpc(unsigned Opc)
bool isTrue16Inst(unsigned Opc)
LLVM_READONLY int32_t getVOPe32(uint32_t Opcode)
LLVM_READONLY int32_t getDPPOp64(uint32_t Opcode)
bool isDPALU_DPP(const MCInstrDesc &OpDesc, const MCInstrInfo &MII, const MCSubtargetInfo &ST)
bool hasAny64BitVGPROperands(const MCInstrDesc &OpDesc, const MCInstrInfo &MII, const MCSubtargetInfo &ST)
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
NodeAddr< DefNode * > Def
Definition RDFGraph.h:384
NodeAddr< UseNode * > Use
Definition RDFGraph.h:385
This is an optimization pass for GlobalISel generic memory operations.
TargetInstrInfo::RegSubRegPair getRegSubRegPair(const MachineOperand &O)
Create RegSubRegPair from a register MachineOperand.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
Definition STLExtras.h:2554
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
Definition STLExtras.h:633
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
Definition InstrProf.h:143
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
auto reverse(ContainerTy &&C)
Definition STLExtras.h:407
MachineInstr * getVRegSubRegDef(const TargetInstrInfo::RegSubRegPair &P, const MachineRegisterInfo &MRI)
Return the defining instruction for a given reg:subreg pair skipping copy like instructions and subre...
char & GCNDPPCombineLegacyID
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
DWARFExpression::Operation Op
iterator_range< pointer_iterator< WrappedIteratorT > > make_pointer_range(RangeT &&Range)
Definition iterator.h:368
bool isOfRegClass(const TargetInstrInfo::RegSubRegPair &P, const TargetRegisterClass &TRC, MachineRegisterInfo &MRI)
Returns true if a reg:subreg pair P has a TRC class.
FunctionPass * createGCNDPPCombinePass()
constexpr RegState getUndefRegState(bool B)
bool execMayBeModifiedBeforeAnyUse(const MachineRegisterInfo &MRI, Register VReg, const MachineInstr &DefMI)
Return false if EXEC is not changed between the def of VReg at DefMI and all its uses.
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58
A pair composed of a register and a sub-register index.