[llvm] Reland "[NFC][MI] Tidy Up RegState enum use (1/2)" (PR #176277)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 15 16:18:53 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-arm
Author: Sam Elliott (lenary)
<details>
<summary>Changes</summary>
This Change is to prepare to make RegState into an enum class. It:
- Updates documentation to match the order in the code.
- Brings the `get<>RegState` functions together and makes them `constexpr`.
- Adopts the `get<>RegState` where RegStates were being chosen with ternary operators in backend code.
- Introduces `hasRegState` to make querying RegState easier once it is an enum class.
- Adopts `hasRegState` where equivalent was done with bitwise arithmetic.
- Introduces `RegState::NoFlags`, which will be used for the lack of flags.
- Documents that `0x1` is a reserved flag value used to detect if someone is passing `true` instead of flags (due to implicit bool to unsigned conversions).
- Updates two calls to `MachineInstrBuilder::addReg` which were passing `false` to the flags operand, to no longer pass a value.
- Documents that `getRegState` seems to have forgotten a call to `getEarlyClobberRegState`.
This PR relands llvm/llvm-project#<!-- -->176091 (commit
1d616cdca3aba9d22f120888bb6b09b75ca90b92) which was reverted in llvm/llvm-project#<!-- -->176190 (commit
6309cd8668fc2ae589f156b23f86821f4ce5b7ea).
---
Patch is 33.83 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/176277.diff
23 Files Affected:
- (modified) llvm/docs/MIRLangRef.rst (+15-15)
- (modified) llvm/include/llvm/CodeGen/MachineInstrBuilder.h (+66-51)
- (modified) llvm/lib/CodeGen/GlobalISel/InlineAsmLowering.cpp (+3-3)
- (modified) llvm/lib/CodeGen/MIRParser/MIParser.cpp (+14-10)
- (modified) llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp (+5-6)
- (modified) llvm/lib/Target/AArch64/AArch64ISelLowering.cpp (+1-1)
- (modified) llvm/lib/Target/AArch64/AArch64InstrInfo.cpp (+17-17)
- (modified) llvm/lib/Target/AMDGPU/GCNDPPCombine.cpp (+1-1)
- (modified) llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp (+2-2)
- (modified) llvm/lib/Target/AMDGPU/R600MachineCFGStructurizer.cpp (+2-2)
- (modified) llvm/lib/Target/AMDGPU/SIInstrInfo.cpp (+8-9)
- (modified) llvm/lib/Target/AMDGPU/SIPeepholeSDWA.cpp (+1-2)
- (modified) llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp (+2-2)
- (modified) llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp (+8-8)
- (modified) llvm/lib/Target/ARM/ARMFixCortexA57AES1742098Pass.cpp (+1-1)
- (modified) llvm/lib/Target/ARM/Thumb2SizeReduction.cpp (+1-1)
- (modified) llvm/lib/Target/Hexagon/HexagonExpandCondsets.cpp (+2-2)
- (modified) llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp (+1-2)
- (modified) llvm/lib/Target/PowerPC/PPCISelLowering.cpp (+1-1)
- (modified) llvm/lib/Target/PowerPC/PPCInstrInfo.cpp (+1-1)
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfo.cpp (+1-2)
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp (+1-1)
- (modified) llvm/lib/Target/X86/X86FixupLEAs.cpp (+2-2)
``````````diff
diff --git a/llvm/docs/MIRLangRef.rst b/llvm/docs/MIRLangRef.rst
index 32c96d197a027..efb20520db1b1 100644
--- a/llvm/docs/MIRLangRef.rst
+++ b/llvm/docs/MIRLangRef.rst
@@ -550,34 +550,26 @@ corresponding internal ``llvm::RegState`` representation:
- Internal Value
- Meaning
- * - ``implicit``
- - ``RegState::Implicit``
- - Not emitted register (e.g., carry, or temporary result).
-
- * - ``implicit-def``
- - ``RegState::ImplicitDefine``
- - ``implicit`` and ``def``
-
* - ``def``
- ``RegState::Define``
- Register definition.
- * - ``dead``
- - ``RegState::Dead``
- - Unused definition.
+ * - ``implicit``
+ - ``RegState::Implicit``
+ - Not emitted register (e.g., carry, or temporary result).
* - ``killed``
- ``RegState::Kill``
- The last use of a register.
+ * - ``dead``
+ - ``RegState::Dead``
+ - Unused definition.
+
* - ``undef``
- ``RegState::Undef``
- Value of the register doesn't matter.
- * - ``internal``
- - ``RegState::InternalRead``
- - Register reads a value that is defined inside the same instruction or bundle.
-
* - ``early-clobber``
- ``RegState::EarlyClobber``
- Register definition happens before uses.
@@ -586,10 +578,18 @@ corresponding internal ``llvm::RegState`` representation:
- ``RegState::Debug``
- Register 'use' is for debugging purpose.
+ * - ``internal``
+ - ``RegState::InternalRead``
+ - Register reads a value that is defined inside the same instruction or bundle.
+
* - ``renamable``
- ``RegState::Renamable``
- Register that may be renamed.
+ * - ``implicit-def``
+ - ``RegState::ImplicitDefine``
+ - ``implicit`` and ``def``
+
.. _subregister-indices:
Subregister Indices
diff --git a/llvm/include/llvm/CodeGen/MachineInstrBuilder.h b/llvm/include/llvm/CodeGen/MachineInstrBuilder.h
index 060f0c41de73a..eb9bcfb7c01a3 100644
--- a/llvm/include/llvm/CodeGen/MachineInstrBuilder.h
+++ b/llvm/include/llvm/CodeGen/MachineInstrBuilder.h
@@ -43,6 +43,11 @@ namespace RegState {
// Keep this in sync with the table in MIRLangRef.rst.
enum {
+ /// No Specific Flags
+ NoFlags = 0x0,
+ // Reserved value, to detect if someone is passing `true` rather than this
+ // enum.
+ _Reserved = 0x1,
/// Register definition.
Define = 0x2,
/// Not emitted register (e.g. carry, or temporary result).
@@ -62,6 +67,7 @@ enum {
InternalRead = 0x100,
/// Register that may be renamed.
Renamable = 0x200,
+ // Combinations of above flags
DefineNoRead = Define | Undef,
ImplicitDefine = Implicit | Define,
ImplicitKill = Implicit | Kill
@@ -69,6 +75,52 @@ enum {
} // end namespace RegState
+constexpr unsigned getDefRegState(bool B) {
+ return B ? RegState::Define : RegState::NoFlags;
+}
+constexpr unsigned getImplRegState(bool B) {
+ return B ? RegState::Implicit : RegState::NoFlags;
+}
+constexpr unsigned getKillRegState(bool B) {
+ return B ? RegState::Kill : RegState::NoFlags;
+}
+constexpr unsigned getDeadRegState(bool B) {
+ return B ? RegState::Dead : RegState::NoFlags;
+}
+constexpr unsigned getUndefRegState(bool B) {
+ return B ? RegState::Undef : RegState::NoFlags;
+}
+constexpr unsigned getEarlyClobberRegState(bool B) {
+ return B ? RegState::EarlyClobber : RegState::NoFlags;
+}
+constexpr unsigned getDebugRegState(bool B) {
+ return B ? RegState::Debug : RegState::NoFlags;
+}
+constexpr unsigned getInternalReadRegState(bool B) {
+ return B ? RegState::InternalRead : RegState::NoFlags;
+}
+constexpr unsigned getRenamableRegState(bool B) {
+ return B ? RegState::Renamable : RegState::NoFlags;
+}
+
+constexpr bool hasRegState(unsigned Value, unsigned Test) {
+ return (Value & Test) == Test;
+}
+
+/// Get all register state flags from machine operand \p RegOp.
+inline unsigned getRegState(const MachineOperand &RegOp) {
+ assert(RegOp.isReg() && "Not a register operand");
+ return getDefRegState(RegOp.isDef()) | getImplRegState(RegOp.isImplicit()) |
+ getKillRegState(RegOp.isKill()) | getDeadRegState(RegOp.isDead()) |
+ getUndefRegState(RegOp.isUndef()) |
+ // FIXME: why is this not included
+ // getEarlyClobberRegState(RegOp.isEarlyClobber()) |
+ getInternalReadRegState(RegOp.isInternalRead()) |
+ getDebugRegState(RegOp.isDebug()) |
+ getRenamableRegState(RegOp.getReg().isPhysical() &&
+ RegOp.isRenamable());
+}
+
/// Set of metadata that should be preserved when using BuildMI(). This provides
/// a more convenient way of preserving certain data from the original
/// instruction.
@@ -138,21 +190,21 @@ class MachineInstrBuilder {
Register getReg(unsigned Idx) const { return MI->getOperand(Idx).getReg(); }
/// Add a new virtual register operand.
- const MachineInstrBuilder &addReg(Register RegNo, unsigned flags = 0,
+ const MachineInstrBuilder &addReg(Register RegNo, unsigned Flags = 0,
unsigned SubReg = 0) const {
- assert((flags & 0x1) == 0 &&
+ assert(!hasRegState(Flags, RegState::_Reserved) &&
"Passing in 'true' to addReg is forbidden! Use enums instead.");
- MI->addOperand(*MF, MachineOperand::CreateReg(RegNo,
- flags & RegState::Define,
- flags & RegState::Implicit,
- flags & RegState::Kill,
- flags & RegState::Dead,
- flags & RegState::Undef,
- flags & RegState::EarlyClobber,
- SubReg,
- flags & RegState::Debug,
- flags & RegState::InternalRead,
- flags & RegState::Renamable));
+ MI->addOperand(*MF, MachineOperand::CreateReg(
+ RegNo, hasRegState(Flags, RegState::Define),
+ hasRegState(Flags, RegState::Implicit),
+ hasRegState(Flags, RegState::Kill),
+ hasRegState(Flags, RegState::Dead),
+ hasRegState(Flags, RegState::Undef),
+ hasRegState(Flags, RegState::EarlyClobber), SubReg,
+ hasRegState(Flags, RegState::Debug),
+ hasRegState(Flags, RegState::InternalRead),
+ hasRegState(Flags, RegState::Renamable)));
+
return *this;
}
@@ -166,7 +218,7 @@ class MachineInstrBuilder {
/// `RegState::Define` when calling this function.
const MachineInstrBuilder &addUse(Register RegNo, unsigned Flags = 0,
unsigned SubReg = 0) const {
- assert(!(Flags & RegState::Define) &&
+ assert(!hasRegState(Flags, RegState::Define) &&
"Misleading addUse defines register, use addReg instead.");
return addReg(RegNo, Flags, SubReg);
}
@@ -556,43 +608,6 @@ LLVM_ABI MachineInstr *buildDbgValueForSpill(
LLVM_ABI void updateDbgValueForSpill(MachineInstr &Orig, int FrameIndex,
Register Reg);
-inline unsigned getDefRegState(bool B) {
- return B ? RegState::Define : 0;
-}
-inline unsigned getImplRegState(bool B) {
- return B ? RegState::Implicit : 0;
-}
-inline unsigned getKillRegState(bool B) {
- return B ? RegState::Kill : 0;
-}
-inline unsigned getDeadRegState(bool B) {
- return B ? RegState::Dead : 0;
-}
-inline unsigned getUndefRegState(bool B) {
- return B ? RegState::Undef : 0;
-}
-inline unsigned getInternalReadRegState(bool B) {
- return B ? RegState::InternalRead : 0;
-}
-inline unsigned getDebugRegState(bool B) {
- return B ? RegState::Debug : 0;
-}
-inline unsigned getRenamableRegState(bool B) {
- return B ? RegState::Renamable : 0;
-}
-
-/// Get all register state flags from machine operand \p RegOp.
-inline unsigned getRegState(const MachineOperand &RegOp) {
- assert(RegOp.isReg() && "Not a register operand");
- return getDefRegState(RegOp.isDef()) | getImplRegState(RegOp.isImplicit()) |
- getKillRegState(RegOp.isKill()) | getDeadRegState(RegOp.isDead()) |
- getUndefRegState(RegOp.isUndef()) |
- getInternalReadRegState(RegOp.isInternalRead()) |
- getDebugRegState(RegOp.isDebug()) |
- getRenamableRegState(RegOp.getReg().isPhysical() &&
- RegOp.isRenamable());
-}
-
/// Helper class for constructing bundles of MachineInstrs.
///
/// MIBundleBuilder can create a bundle from scratch by inserting new
diff --git a/llvm/lib/CodeGen/GlobalISel/InlineAsmLowering.cpp b/llvm/lib/CodeGen/GlobalISel/InlineAsmLowering.cpp
index 2927b075fc360..f16a175af2357 100644
--- a/llvm/lib/CodeGen/GlobalISel/InlineAsmLowering.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/InlineAsmLowering.cpp
@@ -368,9 +368,9 @@ bool InlineAsmLowering::lowerInlineAsm(
Inst.addImm(Flag);
for (Register Reg : OpInfo.Regs) {
- Inst.addReg(Reg,
- RegState::Define | getImplRegState(Reg.isPhysical()) |
- (OpInfo.isEarlyClobber ? RegState::EarlyClobber : 0));
+ Inst.addReg(Reg, RegState::Define |
+ getImplRegState(Reg.isPhysical()) |
+ getEarlyClobberRegState(OpInfo.isEarlyClobber));
}
// Remember this output operand for later processing
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index baac77fbd2dc0..1071cf00aa843 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -1768,7 +1768,7 @@ bool MIParser::assignRegisterTies(MachineInstr &MI,
bool MIParser::parseRegisterOperand(MachineOperand &Dest,
std::optional<unsigned> &TiedDefIdx,
bool IsDef) {
- unsigned Flags = IsDef ? RegState::Define : 0;
+ unsigned Flags = getDefRegState(IsDef);
while (Token.isRegisterFlag()) {
if (parseRegisterFlag(Flags))
return true;
@@ -1795,7 +1795,7 @@ bool MIParser::parseRegisterOperand(MachineOperand &Dest,
return true;
}
MachineRegisterInfo &MRI = MF.getRegInfo();
- if ((Flags & RegState::Define) == 0) {
+ if (!hasRegState(Flags, RegState::Define)) {
if (consumeIfPresent(MIToken::lparen)) {
unsigned Idx;
if (!parseRegisterTiedDefIndex(Idx))
@@ -1843,19 +1843,23 @@ bool MIParser::parseRegisterOperand(MachineOperand &Dest,
return error("generic virtual registers must have a type");
}
- if (Flags & RegState::Define) {
- if (Flags & RegState::Kill)
+ if (hasRegState(Flags, RegState::Define)) {
+ if (hasRegState(Flags, RegState::Kill))
return error("cannot have a killed def operand");
} else {
- if (Flags & RegState::Dead)
+ if (hasRegState(Flags, RegState::Dead))
return error("cannot have a dead use operand");
}
- Dest = MachineOperand::CreateReg(
- Reg, Flags & RegState::Define, Flags & RegState::Implicit,
- Flags & RegState::Kill, Flags & RegState::Dead, Flags & RegState::Undef,
- Flags & RegState::EarlyClobber, SubReg, Flags & RegState::Debug,
- Flags & RegState::InternalRead, Flags & RegState::Renamable);
+ Dest = MachineOperand::CreateReg(Reg, hasRegState(Flags, RegState::Define),
+ hasRegState(Flags, RegState::Implicit),
+ hasRegState(Flags, RegState::Kill),
+ hasRegState(Flags, RegState::Dead),
+ hasRegState(Flags, RegState::Undef),
+ hasRegState(Flags, RegState::EarlyClobber),
+ SubReg, hasRegState(Flags, RegState::Debug),
+ hasRegState(Flags, RegState::InternalRead),
+ hasRegState(Flags, RegState::Renamable));
return false;
}
diff --git a/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp b/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
index 473aaa94242eb..173bcebf5d3ca 100644
--- a/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
@@ -137,8 +137,8 @@ bool AArch64ExpandPseudo::expandMOVImm(MachineBasicBlock &MBB,
unsigned BitSize) {
MachineInstr &MI = *MBBI;
Register DstReg = MI.getOperand(0).getReg();
- uint64_t RenamableState =
- MI.getOperand(0).isRenamable() ? RegState::Renamable : 0;
+ unsigned RenamableState =
+ getRenamableRegState(MI.getOperand(0).isRenamable());
uint64_t Imm = MI.getOperand(1).getImm();
if (DstReg == AArch64::XZR || DstReg == AArch64::WZR) {
@@ -617,7 +617,7 @@ bool AArch64ExpandPseudo::expand_DestructiveOp(
}
// Preserve undef state until DOP's reg is defined.
- unsigned DOPRegState = MI.getOperand(DOPIdx).isUndef() ? RegState::Undef : 0;
+ unsigned DOPRegState = getUndefRegState(MI.getOperand(DOPIdx).isUndef());
//
// Create the destructive operation (if required)
@@ -792,9 +792,8 @@ bool AArch64ExpandPseudo::expandSVESpillFill(MachineBasicBlock &MBB,
assert((Opc == AArch64::LDR_ZXI || Opc == AArch64::STR_ZXI ||
Opc == AArch64::LDR_PXI || Opc == AArch64::STR_PXI) &&
"Unexpected opcode");
- unsigned RState = (Opc == AArch64::LDR_ZXI || Opc == AArch64::LDR_PXI)
- ? RegState::Define
- : 0;
+ unsigned RState =
+ getDefRegState(Opc == AArch64::LDR_ZXI || Opc == AArch64::LDR_PXI);
unsigned sub0 = (Opc == AArch64::LDR_ZXI || Opc == AArch64::STR_ZXI)
? AArch64::zsub0
: AArch64::psub0;
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 2e96abfce72df..273823f028e25 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -3135,7 +3135,7 @@ MachineBasicBlock *AArch64TargetLowering::EmitZTInstr(MachineInstr &MI,
MachineInstrBuilder MIB;
MIB = BuildMI(*BB, MI, MI.getDebugLoc(), TII->get(Opcode))
- .addReg(MI.getOperand(0).getReg(), Op0IsDef ? RegState::Define : 0);
+ .addReg(MI.getOperand(0).getReg(), getDefRegState(Op0IsDef));
for (unsigned I = 1; I < MI.getNumOperands(); ++I)
MIB.add(MI.getOperand(I));
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
index f07211325393d..6b4e4c720e7dc 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -4064,7 +4064,7 @@ MachineInstr *AArch64InstrInfo::emitLdStWithAddr(MachineInstr &MemI,
MRI.constrainRegClass(AM.BaseReg, &AArch64::GPR64spRegClass);
auto B = BuildMI(MBB, MemI, DL, get(Opcode))
.addReg(MemI.getOperand(0).getReg(),
- MemI.mayLoad() ? RegState::Define : 0)
+ getDefRegState(MemI.mayLoad()))
.addReg(AM.BaseReg)
.addReg(AM.ScaledReg)
.addImm(0)
@@ -4085,13 +4085,13 @@ MachineInstr *AArch64InstrInfo::emitLdStWithAddr(MachineInstr &MemI,
else
Opcode = scaledOffsetOpcode(Opcode, Scale);
- auto B = BuildMI(MBB, MemI, DL, get(Opcode))
- .addReg(MemI.getOperand(0).getReg(),
- MemI.mayLoad() ? RegState::Define : 0)
- .addReg(AM.BaseReg)
- .addImm(AM.Displacement / Scale)
- .setMemRefs(MemI.memoperands())
- .setMIFlags(MemI.getFlags());
+ auto B =
+ BuildMI(MBB, MemI, DL, get(Opcode))
+ .addReg(MemI.getOperand(0).getReg(), getDefRegState(MemI.mayLoad()))
+ .addReg(AM.BaseReg)
+ .addImm(AM.Displacement / Scale)
+ .setMemRefs(MemI.memoperands())
+ .setMIFlags(MemI.getFlags());
return B.getInstr();
}
@@ -4110,15 +4110,15 @@ MachineInstr *AArch64InstrInfo::emitLdStWithAddr(MachineInstr &MemI,
BuildMI(MBB, MemI, DL, get(TargetOpcode::COPY), OffsetReg)
.addReg(AM.ScaledReg, 0, AArch64::sub_32);
}
- auto B = BuildMI(MBB, MemI, DL, get(Opcode))
- .addReg(MemI.getOperand(0).getReg(),
- MemI.mayLoad() ? RegState::Define : 0)
- .addReg(AM.BaseReg)
- .addReg(OffsetReg)
- .addImm(AM.Form == ExtAddrMode::Formula::SExtScaledReg)
- .addImm(AM.Scale != 1)
- .setMemRefs(MemI.memoperands())
- .setMIFlags(MemI.getFlags());
+ auto B =
+ BuildMI(MBB, MemI, DL, get(Opcode))
+ .addReg(MemI.getOperand(0).getReg(), getDefRegState(MemI.mayLoad()))
+ .addReg(AM.BaseReg)
+ .addReg(OffsetReg)
+ .addImm(AM.Form == ExtAddrMode::Formula::SExtScaledReg)
+ .addImm(AM.Scale != 1)
+ .setMemRefs(MemI.memoperands())
+ .setMIFlags(MemI.getFlags());
return B.getInstr();
}
diff --git a/llvm/lib/Target/AMDGPU/GCNDPPCombine.cpp b/llvm/lib/Target/AMDGPU/GCNDPPCombine.cpp
index 464cbec6c46bc..1d6f2ec3b3aa5 100644
--- a/llvm/lib/Target/AMDGPU/GCNDPPCombine.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNDPPCombine.cpp
@@ -256,7 +256,7 @@ MachineInstr *GCNDPPCombine::createDPPInst(MachineInstr &OrigMI,
TII->getNamedOperand(MovMI, AMDGPU::OpName::vdst)->getReg()),
*MRI));
auto *Def = getVRegSubRegDef(CombOldVGPR, *MRI);
- DPPInst.addReg(CombOldVGPR.Reg, Def ? 0 : RegState::Undef,
+ DPPInst.addReg(CombOldVGPR.Reg, getUndefRegState(!Def),
CombOldVGPR.SubReg);
++NumOperands;
} else if (TII->isVOPC(DPPOp) || (TII->isVOP3(DPPOp) && OrigOpE32 != -1 &&
diff --git a/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp b/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
index 44a4058525851..9838f1b1ef32a 100644
--- a/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
@@ -1336,8 +1336,8 @@ bool GCNHazardRecognizer::fixVcmpxPermlaneHazards(MachineInstr *MI) {
bool IsUndef = Src0->isUndef();
BuildMI(*MI->getParent(), MI, MI->getDebugLoc(),
TII->get(AMDGPU::V_MOV_B32_e32))
- .addReg(Reg, RegState::Define | (IsUndef ? RegState::Dead : 0))
- .addReg(Reg, IsUndef ? RegState::Undef : RegState::Kill);
+ .addReg(Reg, RegState::Define | getDeadRegState(IsUndef))
+ .addReg(Reg, IsUndef ? RegState::Undef : RegState::Kill);
return true;
}
diff --git a/llvm/lib/Target/AMDGPU/R600MachineCFGStructurizer.cpp b/llvm/lib/Target/AMDGPU/R600MachineCFGStructurizer.cpp
index 0ee5f082aeeef..56d1a194b7384 100644
--- a/llvm/lib/Target/AMDGPU/R600MachineCFGStructurizer.cpp
+++ b/llvm/lib/Target/AMDGPU/R600MachineCFGStructurizer.cpp
@@ -464,7 +464,7 @@ void R600MachineCFGStructurizer::insertCondBranchBefore(
MachineInstr *NewMI = MF->CreateMachineInstr(TII->get(NewOpcode), DL);
MBB->insert(I, NewMI);
MachineInstrBuilder MIB(*MF, NewMI);
- MIB.addReg(OldMI->getOperand(1).getReg(), false);
+ MIB.addReg(OldMI->getOperand(1).getReg());
SHOWNEWINSTR(NewMI);
//erase later oldInstr->eraseFromParent();
}
@@ -476,7 +476,7 @@ void R600MachineCFGStructurizer::insertCondBranchBefore(
MachineInstr *NewInstr = MF->CreateMachineInstr(TII->get(NewOpcode), DL);
//insert before
blk->insert(I, NewInstr);
- MachineInstrBuilder(*MF, NewInstr).addReg(RegNum, false);
+ MachineInstrBuilder(*MF, NewInstr).addReg(RegNum);
SHOWNEWINSTR(NewInstr);
}
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
index 829817c9a027d..be6087c76bd9a 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -2305,11 +2305,11 @@ bool SIInstrInfo::expandPostRAPseudo(MachineInstr &MI) const {
assert(VecReg == MI.getOperand(1).getReg());
MachineInstrBuilder MIB =
- BuildMI(MBB, MI, DL, OpDesc)
- .addReg(RI.getSubReg(VecReg, SubRe...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/176277
More information about the llvm-commits
mailing list