diff --git a/llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.cpp b/llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.cpp @@ -20,9 +20,6 @@ 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 --- a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp @@ -674,7 +674,7 @@ // 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 @@ return false; MachineInstr *OffsetDef = getDefIgnoringCopies(BaseOffset, *MRI); - assert(OffsetDef); - unsigned ImmOffset; MachineBasicBlock *MBB = MI.getParent(); @@ -3036,7 +3034,7 @@ } 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 @@ 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 @@ 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 @@ 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