Commit d8f7c68e authored by Nicolai Hähnle's avatar Nicolai Hähnle Committed by Nicolai Hähnle
Browse files

AMDGPU/SILoadStoreOptimizer: fix a likely bug introduced recently

Summary:
We should check for same instruction class before checking whether they
have the same base address, else we might iterate out of bounds of a
MachineInstr operands list. The InstClass check is also cheaper.

This was introduced in SVN r373630.

Reviewers: tstellar

Subscribers: arsenm, kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, t-tye, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D68690
parent cf6cf0cd
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1665,8 +1665,8 @@ bool SILoadStoreOptimizer::promoteConstantOffsetToImm(
void SILoadStoreOptimizer::addInstToMergeableList(const CombineInfo &CI,
                 std::list<std::list<CombineInfo> > &MergeableInsts) const {
  for (std::list<CombineInfo> &AddrList : MergeableInsts) {
    if (AddrList.front().hasSameBaseAddress(*CI.I) &&
        AddrList.front().InstClass == CI.InstClass) {
    if (AddrList.front().InstClass == CI.InstClass &&
        AddrList.front().hasSameBaseAddress(*CI.I)) {
      AddrList.emplace_back(CI);
      return;
    }