LLVM 24.0.0git
DetectDeadLanes.cpp
Go to the documentation of this file.
1//===- DetectDeadLanes.cpp - SubRegister Lane Usage Analysis --*- C++ -*---===//
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//
9/// \file
10/// Analysis that tracks defined/used subregister lanes across COPY instructions
11/// and instructions that get lowered to a COPY (PHI, REG_SEQUENCE,
12/// INSERT_SUBREG, EXTRACT_SUBREG).
13/// The information is used to detect dead definitions and the usage of
14/// (completely) undefined values and mark the operands as such.
15/// This pass is necessary because the dead/undef status is not obvious anymore
16/// when subregisters are involved.
17///
18/// Example:
19/// %0 = some definition
20/// %1 = IMPLICIT_DEF
21/// %2 = REG_SEQUENCE %0, sub0, %1, sub1
22/// %3 = EXTRACT_SUBREG %2, sub1
23/// = use %3
24/// The %0 definition is dead and %3 contains an undefined value.
25//
26//===----------------------------------------------------------------------===//
27
34#include "llvm/Pass.h"
35#include "llvm/Support/Debug.h"
37
38using namespace llvm;
39
40#define DEBUG_TYPE "detect-dead-lanes"
41
43 const TargetRegisterInfo *TRI)
44 : MRI(MRI), TRI(TRI) {
45 unsigned NumVirtRegs = MRI->getNumVirtRegs();
46 VRegInfos = std::unique_ptr<VRegInfo[]>(new VRegInfo[NumVirtRegs]);
47 WorklistMembers.resize(NumVirtRegs);
48 DefinedByCopy.resize(NumVirtRegs);
49}
50
51/// Returns true if \p MI will get lowered to a series of COPY instructions.
52/// We call this a COPY-like instruction.
53static bool lowersToCopies(const MachineInstr &MI) {
54 // Note: We could support instructions with MCInstrDesc::isRegSequenceLike(),
55 // isExtractSubRegLike(), isInsertSubregLike() in the future even though they
56 // are not lowered to a COPY.
57 switch (MI.getOpcode()) {
58 case TargetOpcode::COPY:
59 case TargetOpcode::PHI:
60 case TargetOpcode::INSERT_SUBREG:
61 case TargetOpcode::REG_SEQUENCE:
62 case TargetOpcode::EXTRACT_SUBREG:
63 return true;
64 }
65 return false;
66}
67
68static bool isCrossCopy(const MachineRegisterInfo &MRI,
69 const MachineInstr &MI,
70 const TargetRegisterClass *DstRC,
71 const MachineOperand &MO) {
73 Register SrcReg = MO.getReg();
74 const TargetRegisterClass *SrcRC = MRI.getRegClass(SrcReg);
75 if (DstRC == SrcRC)
76 return false;
77
78 unsigned SrcSubIdx = MO.getSubReg();
79
81 unsigned DstSubIdx = 0;
82 switch (MI.getOpcode()) {
83 case TargetOpcode::INSERT_SUBREG:
84 if (MO.getOperandNo() == 2)
85 DstSubIdx = MI.getOperand(3).getImm();
86 break;
87 case TargetOpcode::REG_SEQUENCE: {
88 unsigned OpNum = MO.getOperandNo();
89 DstSubIdx = MI.getOperand(OpNum+1).getImm();
90 break;
91 }
92 case TargetOpcode::EXTRACT_SUBREG: {
93 unsigned SubReg = MI.getOperand(2).getImm();
94 SrcSubIdx = TRI.composeSubRegIndices(SubReg, SrcSubIdx);
95 }
96 }
97
98 return !TRI.findCommonRegClass(SrcRC, SrcSubIdx, DstRC, DstSubIdx);
99}
100
101void DeadLaneDetector::addUsedLanesOnOperand(const MachineOperand &MO,
102 LaneBitmask UsedLanes) {
103 if (!MO.readsReg())
104 return;
105 Register MOReg = MO.getReg();
106 if (!MOReg.isVirtual())
107 return;
108
109 unsigned MOSubReg = MO.getSubReg();
110 if (MOSubReg != 0)
111 UsedLanes = TRI->composeSubRegIndexLaneMask(MOSubReg, UsedLanes);
112 UsedLanes &= MRI->getMaxLaneMaskForVReg(MOReg);
113
114 unsigned MORegIdx = MOReg.virtRegIndex();
115 DeadLaneDetector::VRegInfo &MORegInfo = VRegInfos[MORegIdx];
116 LaneBitmask PrevUsedLanes = MORegInfo.UsedLanes;
117 // Any change at all?
118 if ((UsedLanes & ~PrevUsedLanes).none())
119 return;
120
121 // Set UsedLanes and remember instruction for further propagation.
122 MORegInfo.UsedLanes = PrevUsedLanes | UsedLanes;
123 if (DefinedByCopy.test(MORegIdx))
124 PutInWorklist(MORegIdx);
125}
126
127void DeadLaneDetector::transferUsedLanesStep(const MachineInstr &MI,
128 LaneBitmask UsedLanes) {
129 for (const MachineOperand &MO : MI.uses()) {
130 if (!MO.isReg() || !MO.getReg().isVirtual())
131 continue;
132 LaneBitmask UsedOnMO = transferUsedLanes(MI, UsedLanes, MO);
133 addUsedLanesOnOperand(MO, UsedOnMO);
134 }
135}
136
139 LaneBitmask UsedLanes,
140 const MachineOperand &MO) const {
141 unsigned OpNum = MO.getOperandNo();
143 DefinedByCopy[MI.getOperand(0).getReg().virtRegIndex()]);
144
145 switch (MI.getOpcode()) {
146 case TargetOpcode::COPY:
147 case TargetOpcode::PHI:
148 return UsedLanes;
149 case TargetOpcode::REG_SEQUENCE: {
150 assert(OpNum % 2 == 1);
151 unsigned SubIdx = MI.getOperand(OpNum + 1).getImm();
152 return TRI->reverseComposeSubRegIndexLaneMask(SubIdx, UsedLanes);
153 }
154 case TargetOpcode::INSERT_SUBREG: {
155 unsigned SubIdx = MI.getOperand(3).getImm();
156 LaneBitmask MO2UsedLanes =
157 TRI->reverseComposeSubRegIndexLaneMask(SubIdx, UsedLanes);
158 if (OpNum == 2)
159 return MO2UsedLanes;
160
161 const MachineOperand &Def = MI.getOperand(0);
162 Register DefReg = Def.getReg();
163 const TargetRegisterClass *RC = MRI->getRegClass(DefReg);
164 LaneBitmask MO1UsedLanes;
165 if (RC->CoveredBySubRegs)
166 MO1UsedLanes = UsedLanes & ~TRI->getSubRegIndexLaneMask(SubIdx);
167 else
168 MO1UsedLanes = RC->LaneMask;
169
170 assert(OpNum == 1);
171 return MO1UsedLanes;
172 }
173 case TargetOpcode::EXTRACT_SUBREG: {
174 assert(OpNum == 1);
175 unsigned SubIdx = MI.getOperand(2).getImm();
176 return TRI->composeSubRegIndexLaneMask(SubIdx, UsedLanes);
177 }
178 default:
179 llvm_unreachable("function must be called with COPY-like instruction");
180 }
181}
182
183void DeadLaneDetector::transferDefinedLanesStep(const MachineOperand &Use,
184 LaneBitmask DefinedLanes) {
185 if (!Use.readsReg())
186 return;
187 // Check whether the operand writes a vreg and is part of a COPY-like
188 // instruction.
189 const MachineInstr &MI = *Use.getParent();
190 if (MI.getDesc().getNumDefs() != 1)
191 return;
192 // FIXME: PATCHPOINT instructions announce a Def that does not always exist,
193 // they really need to be modeled differently!
194 if (MI.getOpcode() == TargetOpcode::PATCHPOINT)
195 return;
196 const MachineOperand &Def = *MI.defs().begin();
197 Register DefReg = Def.getReg();
198 if (!DefReg.isVirtual())
199 return;
200 unsigned DefRegIdx = DefReg.virtRegIndex();
201 if (!DefinedByCopy.test(DefRegIdx))
202 return;
203
204 unsigned OpNum = Use.getOperandNo();
205 DefinedLanes =
206 TRI->reverseComposeSubRegIndexLaneMask(Use.getSubReg(), DefinedLanes);
207 DefinedLanes = transferDefinedLanes(Def, OpNum, DefinedLanes);
208
209 VRegInfo &RegInfo = VRegInfos[DefRegIdx];
210 LaneBitmask PrevDefinedLanes = RegInfo.DefinedLanes;
211 // Any change at all?
212 if ((DefinedLanes & ~PrevDefinedLanes).none())
213 return;
214
215 RegInfo.DefinedLanes = PrevDefinedLanes | DefinedLanes;
216 PutInWorklist(DefRegIdx);
217}
218
220 const MachineOperand &Def, unsigned OpNum, LaneBitmask DefinedLanes) const {
221 const MachineInstr &MI = *Def.getParent();
222 // Translate DefinedLanes if necessary.
223 switch (MI.getOpcode()) {
224 case TargetOpcode::REG_SEQUENCE: {
225 unsigned SubIdx = MI.getOperand(OpNum + 1).getImm();
226 DefinedLanes = TRI->composeSubRegIndexLaneMask(SubIdx, DefinedLanes);
227 DefinedLanes &= TRI->getSubRegIndexLaneMask(SubIdx);
228 break;
229 }
230 case TargetOpcode::INSERT_SUBREG: {
231 unsigned SubIdx = MI.getOperand(3).getImm();
232 if (OpNum == 2) {
233 DefinedLanes = TRI->composeSubRegIndexLaneMask(SubIdx, DefinedLanes);
234 DefinedLanes &= TRI->getSubRegIndexLaneMask(SubIdx);
235 } else {
236 assert(OpNum == 1 && "INSERT_SUBREG must have two operands");
237 // Ignore lanes defined by operand 2.
238 DefinedLanes &= ~TRI->getSubRegIndexLaneMask(SubIdx);
239 }
240 break;
241 }
242 case TargetOpcode::EXTRACT_SUBREG: {
243 unsigned SubIdx = MI.getOperand(2).getImm();
244 assert(OpNum == 1 && "EXTRACT_SUBREG must have one register operand only");
245 DefinedLanes = TRI->reverseComposeSubRegIndexLaneMask(SubIdx, DefinedLanes);
246 break;
247 }
248 case TargetOpcode::COPY:
249 case TargetOpcode::PHI:
250 break;
251 default:
252 llvm_unreachable("function must be called with COPY-like instruction");
253 }
254
255 assert(Def.getSubReg() == 0 &&
256 "Should not have subregister defs in machine SSA phase");
257 DefinedLanes &= MRI->getMaxLaneMaskForVReg(Def.getReg());
258 return DefinedLanes;
259}
260
261LaneBitmask DeadLaneDetector::determineInitialDefinedLanes(Register Reg) {
262 // Live-In or unused registers have no definition but are considered fully
263 // defined.
264 if (!MRI->hasOneDef(Reg))
265 return LaneBitmask::getAll();
266
267 const MachineOperand &Def = *MRI->def_begin(Reg);
268 const MachineInstr &DefMI = *MRI->getVRegDef(Reg);
269 if (lowersToCopies(DefMI)) {
270 // Start optimisatically with no used or defined lanes for copy
271 // instructions. The following dataflow analysis will add more bits.
272 unsigned RegIdx = Register(Reg).virtRegIndex();
273 DefinedByCopy.set(RegIdx);
274 PutInWorklist(RegIdx);
275
276 if (Def.isDead())
277 return LaneBitmask::getNone();
278
279 // COPY/PHI can copy across unrelated register classes (example: float/int)
280 // with incompatible subregister structure. Do not include these in the
281 // dataflow analysis since we cannot transfer lanemasks in a meaningful way.
282 const TargetRegisterClass *DefRC = MRI->getRegClass(Reg);
283
284 // Determine initially DefinedLanes.
285 LaneBitmask DefinedLanes;
286 for (const MachineOperand &MO : DefMI.uses()) {
287 if (!MO.isReg() || !MO.readsReg())
288 continue;
289 Register MOReg = MO.getReg();
290 if (!MOReg)
291 continue;
292
293 LaneBitmask MODefinedLanes;
294 if (MOReg.isPhysical()) {
295 MODefinedLanes = LaneBitmask::getAll();
296 } else if (isCrossCopy(*MRI, DefMI, DefRC, MO)) {
297 MODefinedLanes = LaneBitmask::getAll();
298 } else {
299 assert(MOReg.isVirtual());
300 if (MRI->hasOneDef(MOReg)) {
301 const MachineInstr &MODefMI = *MRI->getVRegDef(MOReg);
302 // Bits from copy-like operations will be added later.
303 if (lowersToCopies(MODefMI) || MODefMI.isImplicitDef())
304 continue;
305 }
306 unsigned MOSubReg = MO.getSubReg();
307 MODefinedLanes = MRI->getMaxLaneMaskForVReg(MOReg);
308 MODefinedLanes = TRI->reverseComposeSubRegIndexLaneMask(
309 MOSubReg, MODefinedLanes);
310 }
311
312 unsigned OpNum = MO.getOperandNo();
313 DefinedLanes |= transferDefinedLanes(Def, OpNum, MODefinedLanes);
314 }
315 return DefinedLanes;
316 }
317 if (DefMI.isImplicitDef() || Def.isDead())
318 return LaneBitmask::getNone();
319
320 assert(Def.getSubReg() == 0 &&
321 "Should not have subregister defs in machine SSA phase");
322 return MRI->getMaxLaneMaskForVReg(Reg);
323}
324
325LaneBitmask DeadLaneDetector::determineInitialUsedLanes(Register Reg) {
326 LaneBitmask UsedLanes = LaneBitmask::getNone();
327 for (const MachineOperand &MO : MRI->use_nodbg_operands(Reg)) {
328 if (!MO.readsReg())
329 continue;
330
331 const MachineInstr &UseMI = *MO.getParent();
332 if (UseMI.isKill())
333 continue;
334
335 unsigned SubReg = MO.getSubReg();
336 if (lowersToCopies(UseMI)) {
337 assert(UseMI.getDesc().getNumDefs() == 1);
338 const MachineOperand &Def = *UseMI.defs().begin();
339 Register DefReg = Def.getReg();
340 // The used lanes of COPY-like instruction operands are determined by the
341 // following dataflow analysis.
342 if (DefReg.isVirtual()) {
343 // But ignore copies across incompatible register classes.
344 bool CrossCopy = false;
345 if (lowersToCopies(UseMI)) {
346 const TargetRegisterClass *DstRC = MRI->getRegClass(DefReg);
347 CrossCopy = isCrossCopy(*MRI, UseMI, DstRC, MO);
348 if (CrossCopy)
349 LLVM_DEBUG(dbgs() << "Copy across incompatible classes: " << UseMI);
350 }
351
352 if (!CrossCopy)
353 continue;
354 }
355 }
356
357 // Shortcut: All lanes are used.
358 if (SubReg == 0)
359 return MRI->getMaxLaneMaskForVReg(Reg);
360
361 UsedLanes |= TRI->getSubRegIndexLaneMask(SubReg);
362 }
363 return UsedLanes;
364}
365
366namespace {
367
368class DetectDeadLanes {
369public:
370 bool run(MachineFunction &MF);
371
372private:
373 /// update the operand status.
374 /// The first return value shows whether MF been changed.
375 /// The second return value indicates we need to call
376 /// DeadLaneDetector::computeSubRegisterLaneBitInfo and this function again
377 /// to propagate changes.
378 std::pair<bool, bool>
379 modifySubRegisterOperandStatus(const DeadLaneDetector &DLD,
380 MachineFunction &MF);
381
382 bool isUndefRegAtInput(const MachineOperand &MO,
383 const DeadLaneDetector::VRegInfo &RegInfo) const;
384
385 bool isUndefInput(const DeadLaneDetector &DLD, const MachineInstr &MI,
386 const MachineOperand &MO, bool *CrossCopy) const;
387
388 const MachineRegisterInfo *MRI = nullptr;
389 const TargetRegisterInfo *TRI = nullptr;
390};
391
392struct DetectDeadLanesLegacy : public MachineFunctionPass {
393 static char ID;
394 DetectDeadLanesLegacy() : MachineFunctionPass(ID) {}
395
396 StringRef getPassName() const override { return "Detect Dead Lanes"; }
397
398 void getAnalysisUsage(AnalysisUsage &AU) const override {
399 AU.setPreservesCFG();
401 }
402
403 bool runOnMachineFunction(MachineFunction &MF) override {
404 return DetectDeadLanes().run(MF);
405 }
406};
407
408} // end anonymous namespace
409
410char DetectDeadLanesLegacy::ID = 0;
411char &llvm::DetectDeadLanesID = DetectDeadLanesLegacy::ID;
412
413INITIALIZE_PASS(DetectDeadLanesLegacy, DEBUG_TYPE, "Detect Dead Lanes", false,
414 false)
415
416bool DetectDeadLanes::isUndefRegAtInput(
418 unsigned SubReg = MO.getSubReg();
419 LaneBitmask Mask = TRI->getSubRegIndexLaneMask(SubReg);
420 return (RegInfo.DefinedLanes & RegInfo.UsedLanes & Mask).none();
421}
422
423bool DetectDeadLanes::isUndefInput(const DeadLaneDetector &DLD,
424 const MachineInstr &MI,
425 const MachineOperand &MO,
426 bool *CrossCopy) const {
427 if (!MO.isUse())
428 return false;
429 if (!lowersToCopies(MI))
430 return false;
431 const MachineOperand &Def = MI.getOperand(0);
432 Register DefReg = Def.getReg();
433 if (!DefReg.isVirtual())
434 return false;
435 unsigned DefRegIdx = DefReg.virtRegIndex();
436 if (!DLD.isDefinedByCopy(DefRegIdx))
437 return false;
438
439 const DeadLaneDetector::VRegInfo &DefRegInfo = DLD.getVRegInfo(DefRegIdx);
440 LaneBitmask UsedLanes = DLD.transferUsedLanes(MI, DefRegInfo.UsedLanes, MO);
441 if (UsedLanes.any())
442 return false;
443
444 Register MOReg = MO.getReg();
445 if (MOReg.isVirtual()) {
446 const TargetRegisterClass *DstRC = MRI->getRegClass(DefReg);
447 *CrossCopy = isCrossCopy(*MRI, MI, DstRC, MO);
448 }
449 return true;
450}
451
453 // First pass: Populate defs/uses of vregs with initial values
454 unsigned NumVirtRegs = MRI->getNumVirtRegs();
455 for (unsigned RegIdx = 0; RegIdx < NumVirtRegs; ++RegIdx) {
457
458 // Determine used/defined lanes and add copy instructions to worklist.
459 VRegInfo &Info = VRegInfos[RegIdx];
460 Info.DefinedLanes = determineInitialDefinedLanes(Reg);
461 Info.UsedLanes = determineInitialUsedLanes(Reg);
462 }
463
464 // Iterate as long as defined lanes/used lanes keep changing.
465 while (!Worklist.empty()) {
466 unsigned RegIdx = Worklist.front();
467 Worklist.pop_front();
468 WorklistMembers.reset(RegIdx);
469 VRegInfo &Info = VRegInfos[RegIdx];
471
472 // Transfer UsedLanes to operands of DefMI (backwards dataflow).
473 const MachineInstr &MI = *MRI->getVRegDef(Reg);
474 transferUsedLanesStep(MI, Info.UsedLanes);
475 // Transfer DefinedLanes to users of Reg (forward dataflow).
476 for (const MachineOperand &MO : MRI->use_nodbg_operands(Reg))
477 transferDefinedLanesStep(MO, Info.DefinedLanes);
478 }
479
480 LLVM_DEBUG({
481 dbgs() << "Defined/Used lanes:\n";
482 for (unsigned RegIdx = 0; RegIdx < NumVirtRegs; ++RegIdx) {
484 const VRegInfo &Info = VRegInfos[RegIdx];
485 dbgs() << printReg(Reg, nullptr)
486 << " Used: " << PrintLaneMask(Info.UsedLanes)
487 << " Def: " << PrintLaneMask(Info.DefinedLanes) << '\n';
488 }
489 dbgs() << "\n";
490 });
491}
492
493std::pair<bool, bool>
494DetectDeadLanes::modifySubRegisterOperandStatus(const DeadLaneDetector &DLD,
495 MachineFunction &MF) {
496 bool Changed = false;
497 bool Again = false;
498 // Mark operands as dead/unused.
499 for (MachineBasicBlock &MBB : MF) {
500 for (MachineInstr &MI : MBB) {
501 for (MachineOperand &MO : mi_bundle_ops(MI)) {
502 if (!MO.isReg())
503 continue;
504 Register Reg = MO.getReg();
505 if (!Reg.isVirtual())
506 continue;
507 const MachineInstr &OpMI = *MO.getParent();
508 unsigned RegIdx = Reg.virtRegIndex();
509 const DeadLaneDetector::VRegInfo &RegInfo = DLD.getVRegInfo(RegIdx);
510 if (MO.isDef() && !MO.isDead() && RegInfo.UsedLanes.none()) {
512 << "Marking operand '" << MO << "' as dead in " << OpMI);
513 MO.setIsDead();
514 Changed = true;
515 }
516 if (MO.readsReg()) {
517 bool CrossCopy = false;
518 if (isUndefRegAtInput(MO, RegInfo)) {
519 LLVM_DEBUG(dbgs() << "Marking operand '" << MO << "' as undef in "
520 << OpMI);
521 MO.setIsUndef();
522 Changed = true;
523 } else if (isUndefInput(DLD, OpMI, MO, &CrossCopy)) {
524 LLVM_DEBUG(dbgs() << "Marking operand '" << MO << "' as undef in "
525 << OpMI);
526 MO.setIsUndef();
527 Changed = true;
528 if (CrossCopy)
529 Again = true;
530 }
531 }
532 }
533 }
534 }
535
536 return std::make_pair(Changed, Again);
537}
538
542 if (!DetectDeadLanes().run(MF))
543 return PreservedAnalyses::all();
545 PA.preserveSet<CFGAnalyses>();
546 return PA;
547}
548
549bool DetectDeadLanes::run(MachineFunction &MF) {
550 // Don't bother if we won't track subregister liveness later. This pass is
551 // required for correctness if subregister liveness is enabled because the
552 // register coalescer cannot deal with hidden dead defs. However without
553 // subregister liveness enabled, the expected benefits of this pass are small
554 // so we safe the compile time.
555 MRI = &MF.getRegInfo();
556 if (!MRI->subRegLivenessEnabled()) {
557 LLVM_DEBUG(dbgs() << "Skipping Detect dead lanes pass\n");
558 return false;
559 }
560
561 TRI = MRI->getTargetRegisterInfo();
562
563 DeadLaneDetector DLD(MRI, TRI);
564
565 bool Changed = false;
566 bool Again;
567 do {
569 bool LocalChanged;
570 std::tie(LocalChanged, Again) = modifySubRegisterOperandStatus(DLD, MF);
571 Changed |= LocalChanged;
572 } while (Again);
573
574 return Changed;
575}
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
aarch64 promote const
MachineBasicBlock & MBB
static bool isCrossCopy(const MachineRegisterInfo &MRI, const MachineInstr &MI, const TargetRegisterClass *DstRC, const MachineOperand &MO)
static bool lowersToCopies(const MachineInstr &MI)
Returns true if MI will get lowered to a series of COPY instructions.
Analysis that tracks defined/used subregister lanes across COPY instructions and instructions that ge...
#define DEBUG_TYPE
IRTranslator LLVM IR MI
Register Reg
Register const TargetRegisterInfo * TRI
Promote Memory to Register
Definition Mem2Reg.cpp:110
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition PassSupport.h:56
#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
bool test(unsigned Idx) const
Returns true if bit Idx is set.
Definition BitVector.h:482
BitVector & set()
Set all bits in the bitvector.
Definition BitVector.h:366
Represents analyses that only rely on functions' control flow.
Definition Analysis.h:73
LLVM_ABI LaneBitmask transferUsedLanes(const MachineInstr &MI, LaneBitmask UsedLanes, const MachineOperand &MO) const
Given a mask UsedLanes used from the output of instruction MI determine which lanes are used from ope...
LLVM_ABI DeadLaneDetector(const MachineRegisterInfo *MRI, const TargetRegisterInfo *TRI)
bool isDefinedByCopy(unsigned RegIdx) const
LLVM_ABI LaneBitmask transferDefinedLanes(const MachineOperand &Def, unsigned OpNum, LaneBitmask DefinedLanes) const
Given a mask DefinedLanes of lanes defined at operand OpNum of COPY-like instruction,...
LLVM_ABI void computeSubRegisterLaneBitInfo()
Update the DefinedLanes and the UsedLanes for all virtual registers.
const VRegInfo & getVRegInfo(unsigned RegIdx) const
LLVM_ABI PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
const bool CoveredBySubRegs
Whether a combination of subregisters can cover every register in the class.
const LaneBitmask LaneMask
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.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Representation of each machine instruction.
bool isImplicitDef() const
MachineOperand class - Representation of each machine instruction operand.
unsigned getSubReg() const
LLVM_ABI unsigned getOperandNo() const
Returns the index of this operand in the instruction that it belongs to.
bool readsReg() const
readsReg - Returns true if this operand reads the previous value of its register.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
void setIsDead(bool Val=true)
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
void setIsUndef(bool Val=true)
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.
LLVM_ABI LLVM_READONLY MachineInstr * getVRegDef(Register Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
def_iterator def_begin(Register RegNo) const
bool hasOneDef(Register RegNo) const
Return true if there is exactly one operand defining the specified register.
const TargetRegisterInfo * getTargetRegisterInfo() const
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
Wrapper class representing virtual and physical registers.
Definition Register.h:20
static Register index2VirtReg(unsigned Index)
Convert a 0-based index to a virtual register number.
Definition Register.h:72
unsigned virtRegIndex() const
Convert a virtual register number to a 0-based index.
Definition Register.h:87
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
Definition Register.h:79
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
Definition Register.h:83
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
LLVM_ABI unsigned getOperandNo() const
Return the operand # of this use in its User.
Definition Use.cpp:35
Changed
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
NodeAddr< DefNode * > Def
Definition RDFGraph.h:384
This is an optimization pass for GlobalISel generic memory operations.
Printable PrintLaneMask(LaneBitmask LaneMask)
Create Printable object to print LaneBitmasks on a raw_ostream.
Definition LaneBitmask.h:92
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
LLVM_ABI char & DetectDeadLanesID
This pass adds dead/undef flags after analyzing subregister lanes.
iterator_range< MIBundleOperands > mi_bundle_ops(MachineInstr &MI)
LLVM_ABI Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58
Contains a bitmask of which lanes of a given virtual register are defined and which ones are actually...
static constexpr LaneBitmask getAll()
Definition LaneBitmask.h:82
constexpr bool none() const
Definition LaneBitmask.h:52
constexpr bool any() const
Definition LaneBitmask.h:53
static constexpr LaneBitmask getNone()
Definition LaneBitmask.h:81