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
115bool GCNDPPCombine::isShrinkable(MachineInstr &MI) const {
116 unsigned Op = MI.getOpcode();
117 if (!TII->isVOP3(Op)) {
118 return false;
119 }
120 if (!TII->hasVALU32BitEncoding(Op)) {
121 LLVM_DEBUG(dbgs() << " Inst hasn't e32 equivalent\n");
122 return false;
123 }
124 // Do not shrink True16 instructions pre-RA to avoid the restriction in
125 // register allocation from only being able to use 128 VGPRs
127 return false;
128 if (const auto *SDst = TII->getNamedOperand(MI, AMDGPU::OpName::sdst)) {
129 // Give up if there are any uses of the sdst in carry-out or VOPC.
130 // The shrunken form of the instruction would write it to vcc instead of to
131 // a virtual register. If we rewrote the uses the shrinking would be
132 // possible.
133 if (!MRI->use_nodbg_empty(SDst->getReg()))
134 return false;
135 }
136 // check if other than abs|neg modifiers are set (opsel for example)
137 const int64_t Mask = ~(SISrcMods::ABS | SISrcMods::NEG);
138 if (!hasNoImmOrEqual(MI, AMDGPU::OpName::src0_modifiers, 0, Mask) ||
139 !hasNoImmOrEqual(MI, AMDGPU::OpName::src1_modifiers, 0, Mask) ||
140 !hasNoImmOrEqual(MI, AMDGPU::OpName::clamp, 0) ||
141 !hasNoImmOrEqual(MI, AMDGPU::OpName::omod, 0) ||
142 !hasNoImmOrEqual(MI, AMDGPU::OpName::byte_sel, 0)) {
143 LLVM_DEBUG(dbgs() << " Inst has non-default modifiers\n");
144 return false;
145 }
146 return true;
147}
148
149int GCNDPPCombine::getDPPOp(unsigned Op, bool IsShrinkable) const {
150 int DPP32 = AMDGPU::getDPPOp32(Op);
151 if (IsShrinkable) {
152 assert(DPP32 == -1);
153 int E32 = AMDGPU::getVOPe32(Op);
154 DPP32 = (E32 == -1) ? -1 : AMDGPU::getDPPOp32(E32);
155 }
156 if (DPP32 != -1 && TII->pseudoToMCOpcode(DPP32) != -1)
157 return DPP32;
158 int DPP64 = -1;
159 if (ST->hasVOP3DPP())
160 DPP64 = AMDGPU::getDPPOp64(Op);
161 if (DPP64 != -1 && TII->pseudoToMCOpcode(DPP64) != -1)
162 return DPP64;
163 return -1;
164}
165
166// tracks the register operand definition and returns:
167// 1. immediate operand used to initialize the register if found
168// 2. nullptr if the register operand is undef
169// 3. the operand itself otherwise
170MachineOperand *GCNDPPCombine::getOldOpndValue(MachineOperand &OldOpnd) const {
171 auto *Def = getVRegSubRegDef(getRegSubRegPair(OldOpnd), *MRI);
172 if (!Def)
173 return nullptr;
174
175 switch(Def->getOpcode()) {
176 default: break;
177 case AMDGPU::IMPLICIT_DEF:
178 return nullptr;
179 case AMDGPU::COPY:
180 case AMDGPU::V_MOV_B32_e32:
181 case AMDGPU::V_MOV_B64_PSEUDO:
182 case AMDGPU::V_MOV_B64_e32:
183 case AMDGPU::V_MOV_B64_e64: {
184 auto &Op1 = Def->getOperand(1);
185 if (Op1.isImm())
186 return &Op1;
187 break;
188 }
189 }
190 return &OldOpnd;
191}
192
193MachineInstr *GCNDPPCombine::createDPPInst(MachineInstr &OrigMI,
194 MachineInstr &MovMI,
195 RegSubRegPair CombOldVGPR,
196 bool CombBCZ,
197 bool IsShrinkable) const {
198 assert(MovMI.getOpcode() == AMDGPU::V_MOV_B32_dpp ||
199 MovMI.getOpcode() == AMDGPU::V_MOV_B64_dpp ||
200 MovMI.getOpcode() == AMDGPU::V_MOV_B64_DPP_PSEUDO);
201
202 bool HasVOP3DPP = ST->hasVOP3DPP();
203 auto OrigOp = OrigMI.getOpcode();
204 if (ST->useRealTrue16Insts() && AMDGPU::isTrue16Inst(OrigOp)) {
206 dbgs() << " failed: Did not expect any 16-bit uses of dpp values\n");
207 return nullptr;
208 }
209 auto DPPOp = getDPPOp(OrigOp, IsShrinkable);
210 if (DPPOp == -1) {
211 LLVM_DEBUG(dbgs() << " failed: no DPP opcode\n");
212 return nullptr;
213 }
214
215 const int OldIdx = AMDGPU::getNamedOperandIdx(DPPOp, AMDGPU::OpName::old);
216 const int MovDstIdx =
217 AMDGPU::getNamedOperandIdx(MovMI.getOpcode(), AMDGPU::OpName::vdst);
218 if (OldIdx != -1 &&
219 TII->getOpSize(DPPOp, OldIdx) != TII->getOpSize(MovMI, MovDstIdx)) {
220 LLVM_DEBUG(dbgs() << " failed: old operand size differs from dst\n");
221 return nullptr;
222 }
223
224 int OrigOpE32 = AMDGPU::getVOPe32(OrigOp);
225 // Prior checks cover Mask with VOPC condition, but not on purpose
226 auto *RowMaskOpnd = TII->getNamedOperand(MovMI, AMDGPU::OpName::row_mask);
227 assert(RowMaskOpnd && RowMaskOpnd->isImm());
228 auto *BankMaskOpnd = TII->getNamedOperand(MovMI, AMDGPU::OpName::bank_mask);
229 assert(BankMaskOpnd && BankMaskOpnd->isImm());
230 const bool MaskAllLanes =
231 RowMaskOpnd->getImm() == 0xF && BankMaskOpnd->getImm() == 0xF;
232 (void)MaskAllLanes;
233 assert((MaskAllLanes ||
234 !(TII->isVOPC(DPPOp) || (TII->isVOP3(DPPOp) && OrigOpE32 != -1 &&
235 TII->isVOPC(OrigOpE32)))) &&
236 "VOPC cannot form DPP unless mask is full");
237
238 auto DPPInst = BuildMI(*OrigMI.getParent(), OrigMI,
239 OrigMI.getDebugLoc(), TII->get(DPPOp))
240 .setMIFlags(OrigMI.getFlags());
241
242 bool Fail = false;
243 do {
244 int NumOperands = 0;
245 if (auto *Dst = TII->getNamedOperand(OrigMI, AMDGPU::OpName::vdst)) {
246 DPPInst.add(*Dst);
247 ++NumOperands;
248 }
249 if (auto *SDst = TII->getNamedOperand(OrigMI, AMDGPU::OpName::sdst)) {
250 if (AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::sdst)) {
251 DPPInst.add(*SDst);
252 ++NumOperands;
253 }
254 // If we shrunk a 64bit vop3b to 32bits, just ignore the sdst
255 }
256
257 if (OldIdx != -1) {
258 assert(OldIdx == NumOperands);
260 CombOldVGPR,
262 TII->getNamedOperand(MovMI, AMDGPU::OpName::vdst)->getReg()),
263 *MRI));
264 auto *Def = getVRegSubRegDef(CombOldVGPR, *MRI);
265 DPPInst.addReg(CombOldVGPR.Reg, getUndefRegState(!Def),
266 CombOldVGPR.SubReg);
267 ++NumOperands;
268 } else if (TII->isVOPC(DPPOp) || (TII->isVOP3(DPPOp) && OrigOpE32 != -1 &&
269 TII->isVOPC(OrigOpE32))) {
270 // VOPC DPP and VOPC promoted to VOP3 DPP do not have an old operand
271 // because they write to SGPRs not VGPRs
272 } else {
273 // TODO: this discards MAC/FMA instructions for now, let's add it later
274 LLVM_DEBUG(dbgs() << " failed: no old operand in DPP instruction,"
275 " TBD\n");
276 Fail = true;
277 break;
278 }
279
280 auto *Mod0 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src0_modifiers);
281 if (Mod0) {
282 assert(NumOperands == AMDGPU::getNamedOperandIdx(DPPOp,
283 AMDGPU::OpName::src0_modifiers));
284 assert(HasVOP3DPP ||
285 (0LL == (Mod0->getImm() & ~(SISrcMods::ABS | SISrcMods::NEG))));
286 DPPInst.addImm(Mod0->getImm());
287 ++NumOperands;
288 } else if (AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::src0_modifiers)) {
289 DPPInst.addImm(0);
290 ++NumOperands;
291 }
292 auto *Src0 = TII->getNamedOperand(MovMI, AMDGPU::OpName::src0);
293 assert(Src0);
294
295 DPPInst.add(*Src0);
296 DPPInst->getOperand(NumOperands).setIsKill(false);
297 ++NumOperands;
298
299 auto *Mod1 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src1_modifiers);
300 if (Mod1) {
301 assert(NumOperands == AMDGPU::getNamedOperandIdx(DPPOp,
302 AMDGPU::OpName::src1_modifiers));
303 assert(HasVOP3DPP ||
304 (0LL == (Mod1->getImm() & ~(SISrcMods::ABS | SISrcMods::NEG))));
305 DPPInst.addImm(Mod1->getImm());
306 ++NumOperands;
307 } else if (AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::src1_modifiers)) {
308 DPPInst.addImm(0);
309 ++NumOperands;
310 }
311 auto *Src1 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src1);
312 if (Src1) {
313 assert(AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::src1) &&
314 "dpp version of instruction missing src1");
315
316 DPPInst.add(*Src1);
317 ++NumOperands;
318 }
319
320 auto *Mod2 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src2_modifiers);
321 if (Mod2) {
322 assert(NumOperands ==
323 AMDGPU::getNamedOperandIdx(DPPOp, AMDGPU::OpName::src2_modifiers));
324 assert(HasVOP3DPP ||
325 (0LL == (Mod2->getImm() & ~(SISrcMods::ABS | SISrcMods::NEG))));
326 DPPInst.addImm(Mod2->getImm());
327 ++NumOperands;
328 }
329 auto *Src2 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src2);
330 if (Src2) {
331 if (!AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::src2)) {
332 LLVM_DEBUG(dbgs() << " failed: dpp does not have src2\n");
333 Fail = true;
334 break;
335 }
336 DPPInst.add(*Src2);
337 ++NumOperands;
338 }
339
340 if (HasVOP3DPP) {
341 auto *ClampOpr = TII->getNamedOperand(OrigMI, AMDGPU::OpName::clamp);
342 if (ClampOpr && AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::clamp)) {
343 DPPInst.addImm(ClampOpr->getImm());
344 }
345 auto *VdstInOpr = TII->getNamedOperand(OrigMI, AMDGPU::OpName::vdst_in);
346 if (VdstInOpr &&
347 AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::vdst_in)) {
348 DPPInst.add(*VdstInOpr);
349 }
350 auto *OmodOpr = TII->getNamedOperand(OrigMI, AMDGPU::OpName::omod);
351 if (OmodOpr && AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::omod)) {
352 DPPInst.addImm(OmodOpr->getImm());
353 }
354 // Validate OP_SEL has to be set to all 0 and OP_SEL_HI has to be set to
355 // all 1.
356 if (TII->getNamedOperand(OrigMI, AMDGPU::OpName::op_sel)) {
357 int64_t OpSel = 0;
358 OpSel |= (Mod0 ? (!!(Mod0->getImm() & SISrcMods::OP_SEL_0) << 0) : 0);
359 OpSel |= (Mod1 ? (!!(Mod1->getImm() & SISrcMods::OP_SEL_0) << 1) : 0);
360 OpSel |= (Mod2 ? (!!(Mod2->getImm() & SISrcMods::OP_SEL_0) << 2) : 0);
361 if (Mod0 && TII->isVOP3(OrigMI) && !TII->isVOP3P(OrigMI))
362 OpSel |= !!(Mod0->getImm() & SISrcMods::DST_OP_SEL) << 3;
363
364 if (OpSel != 0) {
365 LLVM_DEBUG(dbgs() << " failed: op_sel must be zero\n");
366 Fail = true;
367 break;
368 }
369 if (AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::op_sel))
370 DPPInst.addImm(OpSel);
371 }
372 if (TII->getNamedOperand(OrigMI, AMDGPU::OpName::op_sel_hi)) {
373 int64_t OpSelHi = 0;
374 OpSelHi |= (Mod0 ? (!!(Mod0->getImm() & SISrcMods::OP_SEL_1) << 0) : 0);
375 OpSelHi |= (Mod1 ? (!!(Mod1->getImm() & SISrcMods::OP_SEL_1) << 1) : 0);
376 OpSelHi |= (Mod2 ? (!!(Mod2->getImm() & SISrcMods::OP_SEL_1) << 2) : 0);
377
378 // Only vop3p has op_sel_hi, and all vop3p have 3 operands, so check
379 // the bitmask for 3 op_sel_hi bits set
380 assert(Src2 && "Expected vop3p with 3 operands");
381 if (OpSelHi != 7) {
382 LLVM_DEBUG(dbgs() << " failed: op_sel_hi must be all set to one\n");
383 Fail = true;
384 break;
385 }
386 if (AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::op_sel_hi))
387 DPPInst.addImm(OpSelHi);
388 }
389 auto *NegOpr = TII->getNamedOperand(OrigMI, AMDGPU::OpName::neg_lo);
390 if (NegOpr && AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::neg_lo)) {
391 DPPInst.addImm(NegOpr->getImm());
392 }
393 auto *NegHiOpr = TII->getNamedOperand(OrigMI, AMDGPU::OpName::neg_hi);
394 if (NegHiOpr && AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::neg_hi)) {
395 DPPInst.addImm(NegHiOpr->getImm());
396 }
397 auto *ByteSelOpr = TII->getNamedOperand(OrigMI, AMDGPU::OpName::byte_sel);
398 if (ByteSelOpr &&
399 AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::byte_sel)) {
400 DPPInst.addImm(ByteSelOpr->getImm());
401 }
402 if (MachineOperand *BitOp3 =
403 TII->getNamedOperand(OrigMI, AMDGPU::OpName::bitop3)) {
404 assert(AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::bitop3));
405 DPPInst.add(*BitOp3);
406 }
407 }
408 DPPInst.add(*TII->getNamedOperand(MovMI, AMDGPU::OpName::dpp_ctrl));
409 DPPInst.add(*TII->getNamedOperand(MovMI, AMDGPU::OpName::row_mask));
410 DPPInst.add(*TII->getNamedOperand(MovMI, AMDGPU::OpName::bank_mask));
411 DPPInst.addImm(CombBCZ ? 1 : 0);
412
413 constexpr AMDGPU::OpName Srcs[] = {
414 AMDGPU::OpName::src0, AMDGPU::OpName::src1, AMDGPU::OpName::src2};
415
416 // FIXME: isOperandLegal expects to operate on an completely built
417 // instruction. We should have better legality APIs to check if the
418 // candidate operands will be legal without building the instruction first.
419 for (auto [I, OpName] : enumerate(Srcs)) {
420 int OpIdx = AMDGPU::getNamedOperandIdx(DPPOp, OpName);
421 if (OpIdx == -1)
422 break;
423
424 if (!TII->isOperandLegal(*DPPInst, OpIdx)) {
425 LLVM_DEBUG(dbgs() << " failed: src" << I << " operand is illegal\n");
426 Fail = true;
427 break;
428 }
429 }
430 } while (false);
431
432 if (Fail) {
433 DPPInst.getInstr()->eraseFromParent();
434 return nullptr;
435 }
436 LLVM_DEBUG(dbgs() << " combined: " << *DPPInst.getInstr());
437 return DPPInst.getInstr();
438}
439
440static bool isIdentityValue(unsigned OrigMIOp, MachineOperand *OldOpnd) {
441 assert(OldOpnd->isImm());
442 switch (OrigMIOp) {
443 default: break;
444 case AMDGPU::V_ADD_U32_e32:
445 case AMDGPU::V_ADD_U32_e64:
446 case AMDGPU::V_ADD_CO_U32_e32:
447 case AMDGPU::V_ADD_CO_U32_e64:
448 case AMDGPU::V_OR_B32_e32:
449 case AMDGPU::V_OR_B32_e64:
450 case AMDGPU::V_SUBREV_U32_e32:
451 case AMDGPU::V_SUBREV_U32_e64:
452 case AMDGPU::V_SUBREV_CO_U32_e32:
453 case AMDGPU::V_SUBREV_CO_U32_e64:
454 case AMDGPU::V_MAX_U32_e32:
455 case AMDGPU::V_MAX_U32_e64:
456 case AMDGPU::V_XOR_B32_e32:
457 case AMDGPU::V_XOR_B32_e64:
458 if (OldOpnd->getImm() == 0)
459 return true;
460 break;
461 case AMDGPU::V_AND_B32_e32:
462 case AMDGPU::V_AND_B32_e64:
463 case AMDGPU::V_MIN_U32_e32:
464 case AMDGPU::V_MIN_U32_e64:
465 if (static_cast<uint32_t>(OldOpnd->getImm()) ==
466 std::numeric_limits<uint32_t>::max())
467 return true;
468 break;
469 case AMDGPU::V_MIN_I32_e32:
470 case AMDGPU::V_MIN_I32_e64:
471 if (static_cast<int32_t>(OldOpnd->getImm()) ==
472 std::numeric_limits<int32_t>::max())
473 return true;
474 break;
475 case AMDGPU::V_MAX_I32_e32:
476 case AMDGPU::V_MAX_I32_e64:
477 if (static_cast<int32_t>(OldOpnd->getImm()) ==
478 std::numeric_limits<int32_t>::min())
479 return true;
480 break;
481 case AMDGPU::V_MUL_I32_I24_e32:
482 case AMDGPU::V_MUL_I32_I24_e64:
483 case AMDGPU::V_MUL_U32_U24_e32:
484 case AMDGPU::V_MUL_U32_U24_e64:
485 if (OldOpnd->getImm() == 1)
486 return true;
487 break;
488 case AMDGPU::V_MIN_F32_e32:
489 case AMDGPU::V_MIN_F32_e64:
490 if (static_cast<uint32_t>(OldOpnd->getImm()) == /*+inf=*/0x7F800000)
491 return true;
492 break;
493 case AMDGPU::V_MAX_F32_e32:
494 case AMDGPU::V_MAX_F32_e64:
495 if (static_cast<uint32_t>(OldOpnd->getImm()) == /*-inf=*/0xFF800000)
496 return true;
497 break;
498 case AMDGPU::V_MIN_F64_e64:
499 case AMDGPU::V_MIN_NUM_F64_e64:
500 if (static_cast<uint64_t>(OldOpnd->getImm()) == /*+inf=*/0x7FF0000000000000)
501 return true;
502 break;
503 case AMDGPU::V_MAX_F64_e64:
504 case AMDGPU::V_MAX_NUM_F64_e64:
505 if (static_cast<uint64_t>(OldOpnd->getImm()) == /*-inf=*/0xFFF0000000000000)
506 return true;
507 break;
508 case AMDGPU::V_MIN_F16_e32:
509 case AMDGPU::V_MIN_F16_e64:
510 case AMDGPU::V_MIN_F16_t16_e32:
511 case AMDGPU::V_MIN_F16_t16_e64:
512 case AMDGPU::V_MIN_F16_fake16_e32:
513 case AMDGPU::V_MIN_F16_fake16_e64:
514 if (static_cast<uint16_t>(OldOpnd->getImm()) == /*+inf=*/0x7C00)
515 return true;
516 break;
517 case AMDGPU::V_MAX_F16_e32:
518 case AMDGPU::V_MAX_F16_e64:
519 case AMDGPU::V_MAX_F16_t16_e32:
520 case AMDGPU::V_MAX_F16_t16_e64:
521 case AMDGPU::V_MAX_F16_fake16_e32:
522 case AMDGPU::V_MAX_F16_fake16_e64:
523 if (static_cast<uint16_t>(OldOpnd->getImm()) == /*-inf=*/0xFC00)
524 return true;
525 break;
526 }
527 return false;
528}
529
530MachineInstr *GCNDPPCombine::createDPPInst(
531 MachineInstr &OrigMI, MachineInstr &MovMI, RegSubRegPair CombOldVGPR,
532 MachineOperand *OldOpndValue, bool CombBCZ, bool IsShrinkable) const {
533 assert(CombOldVGPR.Reg);
534 if (!CombBCZ && OldOpndValue && OldOpndValue->isImm()) {
535 auto *Src1 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src1);
536 if (!Src1 || !Src1->isReg()) {
537 LLVM_DEBUG(dbgs() << " failed: no src1 or it isn't a register\n");
538 return nullptr;
539 }
540 if (!isIdentityValue(OrigMI.getOpcode(), OldOpndValue)) {
541 LLVM_DEBUG(dbgs() << " failed: old immediate isn't an identity\n");
542 return nullptr;
543 }
544 CombOldVGPR = getRegSubRegPair(*Src1);
545 auto *MovDst = TII->getNamedOperand(MovMI, AMDGPU::OpName::vdst);
546 const TargetRegisterClass *RC = MRI->getRegClass(MovDst->getReg());
547 if (!isOfRegClass(CombOldVGPR, *RC, *MRI)) {
548 LLVM_DEBUG(dbgs() << " failed: src1 has wrong register class\n");
549 return nullptr;
550 }
551 }
552 return createDPPInst(OrigMI, MovMI, CombOldVGPR, CombBCZ, IsShrinkable);
553}
554
555// returns true if MI doesn't have OpndName immediate operand or the
556// operand has Value
557bool GCNDPPCombine::hasNoImmOrEqual(MachineInstr &MI, AMDGPU::OpName OpndName,
558 int64_t Value, int64_t Mask) const {
559 auto *Imm = TII->getNamedOperand(MI, OpndName);
560 if (!Imm)
561 return true;
562
563 assert(Imm->isImm());
564 return (Imm->getImm() & Mask) == Value;
565}
566
567bool GCNDPPCombine::combineDPPMov(MachineInstr &MovMI) const {
568 assert(MovMI.getOpcode() == AMDGPU::V_MOV_B32_dpp ||
569 MovMI.getOpcode() == AMDGPU::V_MOV_B64_dpp ||
570 MovMI.getOpcode() == AMDGPU::V_MOV_B64_DPP_PSEUDO);
571 LLVM_DEBUG(dbgs() << "\nDPP combine: " << MovMI);
572
573 auto *DstOpnd = TII->getNamedOperand(MovMI, AMDGPU::OpName::vdst);
574 assert(DstOpnd && DstOpnd->isReg());
575 auto DPPMovReg = DstOpnd->getReg();
576 if (DPPMovReg.isPhysical()) {
577 LLVM_DEBUG(dbgs() << " failed: dpp move writes physreg\n");
578 return false;
579 }
580 if (execMayBeModifiedBeforeAnyUse(*MRI, DPPMovReg, MovMI)) {
581 LLVM_DEBUG(dbgs() << " failed: EXEC mask should remain the same"
582 " for all uses\n");
583 return false;
584 }
585
586 auto *DppCtrl = TII->getNamedOperand(MovMI, AMDGPU::OpName::dpp_ctrl);
587 assert(DppCtrl && DppCtrl->isImm());
588 unsigned DppCtrlVal = DppCtrl->getImm();
589 if ((MovMI.getOpcode() == AMDGPU::V_MOV_B64_DPP_PSEUDO ||
590 MovMI.getOpcode() == AMDGPU::V_MOV_B64_dpp)) {
591 if (!ST->hasFeature(AMDGPU::FeatureDPALU_DPP)) {
592 LLVM_DEBUG(dbgs() << " failed: 64 bit dpp move is unsupported\n");
593 // Split it.
594 return false;
595 }
596 if (!AMDGPU::isLegalDPALU_DPPControl(*ST, DppCtrlVal)) {
597 LLVM_DEBUG(dbgs() << " failed: 64 bit dpp move uses unsupported"
598 " control value\n");
599 // Let it split, then control may become legal.
600 return false;
601 }
602 }
603
604 auto *RowMaskOpnd = TII->getNamedOperand(MovMI, AMDGPU::OpName::row_mask);
605 assert(RowMaskOpnd && RowMaskOpnd->isImm());
606 auto *BankMaskOpnd = TII->getNamedOperand(MovMI, AMDGPU::OpName::bank_mask);
607 assert(BankMaskOpnd && BankMaskOpnd->isImm());
608 const bool MaskAllLanes = RowMaskOpnd->getImm() == 0xF &&
609 BankMaskOpnd->getImm() == 0xF;
610
611 auto *BCZOpnd = TII->getNamedOperand(MovMI, AMDGPU::OpName::bound_ctrl);
612 assert(BCZOpnd && BCZOpnd->isImm());
613 bool BoundCtrlZero = BCZOpnd->getImm();
614
615 auto *OldOpnd = TII->getNamedOperand(MovMI, AMDGPU::OpName::old);
616 auto *SrcOpnd = TII->getNamedOperand(MovMI, AMDGPU::OpName::src0);
617 assert(OldOpnd && OldOpnd->isReg());
618 assert(SrcOpnd && SrcOpnd->isReg());
619 if (OldOpnd->getReg().isPhysical() || SrcOpnd->getReg().isPhysical()) {
620 LLVM_DEBUG(dbgs() << " failed: dpp move reads physreg\n");
621 return false;
622 }
623
624 auto * const OldOpndValue = getOldOpndValue(*OldOpnd);
625 // OldOpndValue is either undef (IMPLICIT_DEF) or immediate or something else
626 // We could use: assert(!OldOpndValue || OldOpndValue->isImm())
627 // but the third option is used to distinguish undef from non-immediate
628 // to reuse IMPLICIT_DEF instruction later
629 assert(!OldOpndValue || OldOpndValue->isImm() || OldOpndValue == OldOpnd);
630
631 bool CombBCZ = false;
632
633 if (MaskAllLanes && BoundCtrlZero) { // [1]
634 CombBCZ = true;
635 } else {
636 if (!OldOpndValue || !OldOpndValue->isImm()) {
637 LLVM_DEBUG(dbgs() << " failed: the DPP mov isn't combinable\n");
638 return false;
639 }
640
641 if (OldOpndValue->getImm() == 0) {
642 if (MaskAllLanes) {
643 assert(!BoundCtrlZero); // by check [1]
644 CombBCZ = true;
645 }
646 } else if (BoundCtrlZero) {
647 assert(!MaskAllLanes); // by check [1]
648 LLVM_DEBUG(dbgs() <<
649 " failed: old!=0 and bctrl:0 and not all lanes isn't combinable\n");
650 return false;
651 }
652 }
653
654 LLVM_DEBUG(dbgs() << " old=";
655 if (!OldOpndValue)
656 dbgs() << "undef";
657 else
658 dbgs() << *OldOpndValue;
659 dbgs() << ", bound_ctrl=" << CombBCZ << '\n');
660
661 SmallVector<MachineInstr*, 4> OrigMIs, DPPMIs;
662 DenseMap<MachineInstr*, SmallVector<unsigned, 4>> RegSeqWithOpNos;
663 auto CombOldVGPR = getRegSubRegPair(*OldOpnd);
664 // try to reuse previous old reg if its undefined (IMPLICIT_DEF)
665 if (CombBCZ && OldOpndValue) { // CombOldVGPR should be undef
666 const TargetRegisterClass *RC = MRI->getRegClass(DPPMovReg);
667 CombOldVGPR = RegSubRegPair(
669 auto UndefInst = BuildMI(*MovMI.getParent(), MovMI, MovMI.getDebugLoc(),
670 TII->get(AMDGPU::IMPLICIT_DEF), CombOldVGPR.Reg);
671 DPPMIs.push_back(UndefInst.getInstr());
672 }
673
674 OrigMIs.push_back(&MovMI);
675 bool Rollback = true;
676 const SIRegisterInfo *TRI = ST->getRegisterInfo();
679
680 while (!Uses.empty()) {
681 MachineOperand *Use = Uses.pop_back_val();
682 Rollback = true;
683
684 auto &OrigMI = *Use->getParent();
685 LLVM_DEBUG(dbgs() << " try: " << OrigMI);
686
687 auto OrigOp = OrigMI.getOpcode();
688 assert((TII->get(OrigOp).getSize() != 4 || !AMDGPU::isTrue16Inst(OrigOp)) &&
689 "There should not be e32 True16 instructions pre-RA");
690 if (OrigOp == AMDGPU::REG_SEQUENCE) {
691 // A different reg is a forwarded lane of a nested REG_SEQUENCE.
692 if (Use->getReg() != DPPMovReg) {
693 LLVM_DEBUG(dbgs() << " failed: nested REG_SEQUENCE\n");
694 break;
695 }
696
697 Register FwdReg = OrigMI.getOperand(0).getReg();
698
699 if (execMayBeModifiedBeforeAnyUse(*MRI, FwdReg, OrigMI)) {
700 LLVM_DEBUG(dbgs() << " failed: EXEC mask should remain the same"
701 " for all uses\n");
702 break;
703 }
704
705 // The DPP mov reg can appear in several operands, each with its own
706 // subreg index: REG_SEQUENCE inputs never overlap.
707 unsigned OpNo = OrigMI.getOperandNo(Use);
708 unsigned FwdSubReg = OrigMI.getOperand(OpNo + 1).getImm();
709
710 // Marking the operand undef is unsound if another read consumes the lane.
711 LaneBitmask FwdLanes = TRI->getSubRegIndexLaneMask(FwdSubReg);
712 if (llvm::any_of(
713 MRI->use_nodbg_operands(FwdReg), [&](const MachineOperand &Op) {
714 return Op.getSubReg() != FwdSubReg &&
715 (TRI->getSubRegIndexLaneMask(Op.getSubReg()) & FwdLanes)
716 .any();
717 })) {
718 LLVM_DEBUG(dbgs() << " failed: REG_SEQUENCE lane has other reads\n");
719 break;
720 }
721
722 for (MachineOperand &Op : MRI->use_nodbg_operands(FwdReg))
723 if (Op.getSubReg() == FwdSubReg)
724 Uses.push_back(&Op);
725
726 RegSeqWithOpNos[&OrigMI].push_back(OpNo);
727 continue;
728 }
729
730 bool IsShrinkable = isShrinkable(OrigMI);
731 if (!(IsShrinkable ||
732 ((TII->isVOP3P(OrigOp) || TII->isVOPC(OrigOp) ||
733 TII->isVOP3(OrigOp)) &&
734 ST->hasVOP3DPP()) ||
735 TII->isVOP1(OrigOp) || TII->isVOP2(OrigOp))) {
736 LLVM_DEBUG(dbgs() << " failed: not VOP1/2/3/3P/C\n");
737 break;
738 }
739 if (OrigMI.modifiesRegister(AMDGPU::EXEC, ST->getRegisterInfo())) {
740 LLVM_DEBUG(dbgs() << " failed: can't combine v_cmpx\n");
741 break;
742 }
743
744 auto *Src0 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src0);
745 auto *Src1 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src1);
746 if (Use != Src0 && !(Use == Src1 && OrigMI.isCommutable())) { // [1]
747 LLVM_DEBUG(dbgs() << " failed: no suitable operands\n");
748 break;
749 }
750
751 auto *Src2 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src2);
752 assert(Src0 && "Src1 without Src0?");
753 if ((Use == Src0 && ((Src1 && Src1->isIdenticalTo(*Src0)) ||
754 (Src2 && Src2->isIdenticalTo(*Src0)))) ||
755 (Use == Src1 && (Src1->isIdenticalTo(*Src0) ||
756 (Src2 && Src2->isIdenticalTo(*Src1))))) {
758 dbgs()
759 << " " << OrigMI
760 << " failed: DPP register is used more than once per instruction\n");
761 break;
762 }
763
764 // We have to be careful to prevent trying to fold into the first source
765 // operand of instructions that apply DPP to the second source operand.
766 // This could be directly, or when folding into an instruction that will
767 // get commuted into one.
768 int FoldedOp =
769 (Use == Src0) ? static_cast<int>(OrigOp) : TII->commuteOpcode(OrigOp);
770 if (FoldedOp < 0 || TII->isSrc1DPPRevOpcode(*ST, FoldedOp)) {
772 dbgs() << " failed: Use operand cannot have DPP applied to it\n");
773 break;
774 }
775
776 // Without DPALU DPP there are no 64-bit DPP encodings. The 64-bit move is
777 // rejected above, but a 32-bit move folded into a source of a 64-bit
778 // instruction reaches here, so the operands have to be checked too.
779 if (AMDGPU::isDPALU_DPP(TII->get(OrigOp), *TII, *ST)) {
780 if (!ST->hasFeature(AMDGPU::FeatureDPALU_DPP)) {
781 LLVM_DEBUG(dbgs() << " " << OrigMI
782 << " failed: DPP ALU DPP is not supported\n");
783 break;
784 }
785
786 if (!AMDGPU::isLegalDPALU_DPPControl(*ST, DppCtrlVal)) {
787 LLVM_DEBUG(dbgs() << " " << OrigMI
788 << " failed: not valid 64-bit DPP control value\n");
789 break;
790 }
791 }
792
793 LLVM_DEBUG(dbgs() << " combining: " << OrigMI);
794 if (Use == Src0) {
795 if (auto *DPPInst = createDPPInst(OrigMI, MovMI, CombOldVGPR,
796 OldOpndValue, CombBCZ, IsShrinkable)) {
797 DPPMIs.push_back(DPPInst);
798 Rollback = false;
799 }
800 } else {
801 assert(Use == Src1 && OrigMI.isCommutable()); // by check [1]
802 auto *BB = OrigMI.getParent();
803 auto *NewMI = BB->getParent()->CloneMachineInstr(&OrigMI);
804 BB->insert(OrigMI, NewMI);
805 if (TII->commuteInstruction(*NewMI)) {
806 LLVM_DEBUG(dbgs() << " commuted: " << *NewMI);
807 if (auto *DPPInst =
808 createDPPInst(*NewMI, MovMI, CombOldVGPR, OldOpndValue, CombBCZ,
809 IsShrinkable)) {
810 DPPMIs.push_back(DPPInst);
811 Rollback = false;
812 }
813 } else
814 LLVM_DEBUG(dbgs() << " failed: cannot be commuted\n");
815 NewMI->eraseFromParent();
816 }
817 if (Rollback)
818 break;
819 OrigMIs.push_back(&OrigMI);
820 }
821
822 Rollback |= !Uses.empty();
823
824 for (auto *MI : *(Rollback? &DPPMIs : &OrigMIs))
825 MI->eraseFromParent();
826
827 if (!Rollback) {
828 for (auto &S : RegSeqWithOpNos) {
829 if (MRI->use_nodbg_empty(S.first->getOperand(0).getReg())) {
830 S.first->eraseFromParent();
831 continue;
832 }
833 while (!S.second.empty())
834 S.first->getOperand(S.second.pop_back_val()).setIsUndef();
835 }
836 }
837
838 return !Rollback;
839}
840
841bool GCNDPPCombineLegacy::runOnMachineFunction(MachineFunction &MF) {
842 if (skipFunction(MF.getFunction()))
843 return false;
844
845 return GCNDPPCombine().run(MF);
846}
847
848bool GCNDPPCombine::run(MachineFunction &MF) {
849 ST = &MF.getSubtarget<GCNSubtarget>();
850 if (!ST->hasDPP())
851 return false;
852
853 MRI = &MF.getRegInfo();
854 TII = ST->getInstrInfo();
855
856 bool Changed = false;
857 for (auto &MBB : MF) {
858 for (MachineInstr &MI : llvm::make_early_inc_range(llvm::reverse(MBB))) {
859 if (MI.getOpcode() == AMDGPU::V_MOV_B32_dpp && combineDPPMov(MI)) {
860 Changed = true;
861 ++NumDPPMovsCombined;
862 } else if (MI.getOpcode() == AMDGPU::V_MOV_B64_DPP_PSEUDO ||
863 MI.getOpcode() == AMDGPU::V_MOV_B64_dpp) {
864 if (ST->hasDPALU_DPP() && combineDPPMov(MI)) {
865 Changed = true;
866 ++NumDPPMovsCombined;
867 } else {
868 auto Split = TII->expandMovDPP64(MI);
869 for (auto *M : {Split.first, Split.second}) {
870 if (M && combineDPPMov(*M))
871 ++NumDPPMovsCombined;
872 }
873 Changed = true;
874 }
875 }
876 }
877 }
878 return Changed;
879}
880
883 MFPropsModifier _(*this, MF);
884
885 if (MF.getFunction().hasOptNone())
886 return PreservedAnalyses::all();
887
888 bool Changed = GCNDPPCombine().run(MF);
889 if (!Changed)
890 return PreservedAnalyses::all();
891
893 PA.preserveSet<CFGAnalyses>();
894 return PA;
895}
#define Fail
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t uint64_t
uint64_t Imm
Provides AMDGPU specific target descriptions.
MachineBasicBlock & MBB
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
Register const TargetRegisterInfo * TRI
Promote Memory to Register
Definition Mem2Reg.cpp:110
if(PassOpts->AAPipeline)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition PassSupport.h:56
MachineRegisterInfo & MRI
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:280
Represents analyses that only rely on functions' control flow.
Definition Analysis.h:73
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 getOperandNo(const_mop_iterator I) const
Returns the number of the operand iterator I points to.
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
LLVM_READONLY int32_t getDPPOp32(uint32_t Opcode)
LLVM_READNONE bool isLegalDPALU_DPPControl(const MCSubtargetInfo &ST, unsigned DC)
LLVM_READONLY bool hasNamedOperand(uint32_t Opcode, OpName NamedIdx)
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)
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:2570
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:649
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.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1762
auto reverse(ContainerTy &&C)
Definition STLExtras.h:408
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.
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.