[llvm] ea09a42 - [AMDGPU] Assume getDefIgnoringCopies will succeed. NFC.
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 19 03:14:02 PDT 2022
Author: Jay Foad
Date: 2022-10-19T11:10:00+01:00
New Revision: ea09a426a94cdd1cdf96cf0d22f16f566aee3916
URL: https://github.com/llvm/llvm-project/commit/ea09a426a94cdd1cdf96cf0d22f16f566aee3916
DIFF: https://github.com/llvm/llvm-project/commit/ea09a426a94cdd1cdf96cf0d22f16f566aee3916.diff
LOG: [AMDGPU] Assume getDefIgnoringCopies will succeed. NFC.
getDefIgnoringCopies and getSrcRegIgnoringCopies should not fail on
valid MIR, so don't bother to check for failure.
Differential Revision: https://reviews.llvm.org/D136238
Added:
Modified:
llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.cpp
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.cpp b/llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.cpp
index 4b71d11f0c3b..0aa2c88ad41b 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.cpp
@@ -20,9 +20,6 @@ std::pair<Register, unsigned>
AMDGPU::getBaseWithConstantOffset(MachineRegisterInfo &MRI, Register Reg,
GISelKnownBits *KnownBits) {
MachineInstr *Def = getDefIgnoringCopies(Reg, MRI);
- if (!Def)
- return std::make_pair(Reg, 0);
-
if (Def->getOpcode() == TargetOpcode::G_CONSTANT) {
unsigned Offset;
const MachineOperand &Op = Def->getOperand(1);
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
index 99ce353cec8a..7f41e8593692 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
@@ -674,7 +674,7 @@ bool AMDGPUInstructionSelector::selectG_BUILD_VECTOR(MachineInstr &MI) const {
// TODO: This should probably be a combine somewhere
// (build_vector $src0, undef) -> copy $src0
MachineInstr *Src1Def = getDefIgnoringCopies(Src1, *MRI);
- if (Src1Def && Src1Def->getOpcode() == AMDGPU::G_IMPLICIT_DEF) {
+ if (Src1Def->getOpcode() == AMDGPU::G_IMPLICIT_DEF) {
MI.setDesc(TII.get(AMDGPU::COPY));
MI.removeOperand(2);
const auto &RC =
@@ -1451,8 +1451,6 @@ bool AMDGPUInstructionSelector::selectDSGWSIntrinsic(MachineInstr &MI,
return false;
MachineInstr *OffsetDef = getDefIgnoringCopies(BaseOffset, *MRI);
- assert(OffsetDef);
-
unsigned ImmOffset;
MachineBasicBlock *MBB = MI.getParent();
@@ -3036,7 +3034,7 @@ bool AMDGPUInstructionSelector::selectGlobalLoadLds(MachineInstr &MI) const{
} else if (AddrDef->MI->getOpcode() == AMDGPU::G_PTR_ADD) {
Register SAddr =
getSrcRegIgnoringCopies(AddrDef->MI->getOperand(1).getReg(), *MRI);
- if (SAddr && isSGPR(SAddr)) {
+ if (isSGPR(SAddr)) {
Register PtrBaseOffset = AddrDef->MI->getOperand(2).getReg();
if (Register Off = matchZeroExtendFromS32(*MRI, PtrBaseOffset)) {
Addr = SAddr;
@@ -3330,13 +3328,13 @@ std::pair<Register, unsigned> AMDGPUInstructionSelector::selectVOP3ModsImpl(
unsigned Mods = 0;
MachineInstr *MI = getDefIgnoringCopies(Src, *MRI);
- if (MI && MI->getOpcode() == AMDGPU::G_FNEG) {
+ if (MI->getOpcode() == AMDGPU::G_FNEG) {
Src = MI->getOperand(1).getReg();
Mods |= SISrcMods::NEG;
MI = getDefIgnoringCopies(Src, *MRI);
}
- if (AllowAbs && MI && MI->getOpcode() == AMDGPU::G_FABS) {
+ if (AllowAbs && MI->getOpcode() == AMDGPU::G_FABS) {
Src = MI->getOperand(1).getReg();
Mods |= SISrcMods::ABS;
}
@@ -3436,8 +3434,7 @@ InstructionSelector::ComplexRendererFns
AMDGPUInstructionSelector::selectVOP3NoMods(MachineOperand &Root) const {
Register Reg = Root.getReg();
const MachineInstr *Def = getDefIgnoringCopies(Reg, *MRI);
- if (Def && (Def->getOpcode() == AMDGPU::G_FNEG ||
- Def->getOpcode() == AMDGPU::G_FABS))
+ if (Def->getOpcode() == AMDGPU::G_FNEG || Def->getOpcode() == AMDGPU::G_FABS)
return {};
return {{
[=](MachineInstrBuilder &MIB) { MIB.addReg(Reg); },
@@ -3826,7 +3823,7 @@ AMDGPUInstructionSelector::selectGlobalSAddr(MachineOperand &Root) const {
Register SAddr =
getSrcRegIgnoringCopies(AddrDef->MI->getOperand(1).getReg(), *MRI);
- if (SAddr && isSGPR(SAddr)) {
+ if (isSGPR(SAddr)) {
Register PtrBaseOffset = AddrDef->MI->getOperand(2).getReg();
// It's possible voffset is an SGPR here, but the copy to VGPR will be
More information about the llvm-commits
mailing list