diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp --- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp +++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp @@ -2633,26 +2633,22 @@ bool SIInstrInfo::checkInstOffsetsDoNotOverlap(const MachineInstr &MIa, const MachineInstr &MIb) const { - const MachineOperand *BaseOp0, *BaseOp1; + SmallVector BaseOps0, BaseOps1; int64_t Offset0, Offset1; + if (!getMemOperandsWithOffset(MIa, BaseOps0, Offset0, &RI) || + !getMemOperandsWithOffset(MIb, BaseOps1, Offset1, &RI)) + return false; - if (getMemOperandWithOffset(MIa, BaseOp0, Offset0, &RI) && - getMemOperandWithOffset(MIb, BaseOp1, Offset1, &RI)) { - if (!BaseOp0->isIdenticalTo(*BaseOp1)) - return false; + if (!memOpsHaveSameBaseOperands(BaseOps0, BaseOps1)) + return false; - if (!MIa.hasOneMemOperand() || !MIb.hasOneMemOperand()) { - // FIXME: Handle ds_read2 / ds_write2. - return false; - } - unsigned Width0 = (*MIa.memoperands_begin())->getSize(); - unsigned Width1 = (*MIb.memoperands_begin())->getSize(); - if (offsetsDoNotOverlap(Width0, Offset0, Width1, Offset1)) { - return true; - } + if (!MIa.hasOneMemOperand() || !MIb.hasOneMemOperand()) { + // FIXME: Handle ds_read2 / ds_write2. + return false; } - - return false; + unsigned Width0 = MIa.memoperands().front()->getSize(); + unsigned Width1 = MIb.memoperands().front()->getSize(); + return offsetsDoNotOverlap(Width0, Offset0, Width1, Offset1); } bool SIInstrInfo::areMemAccessesTriviallyDisjoint(const MachineInstr &MIa,