Index: lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp =================================================================== --- lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp +++ lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp @@ -1118,8 +1118,9 @@ --MBBI; MachineInstr &MI = *MBBI; - // Don't count DBG_VALUE instructions towards the search limit. - if (!MI.isDebugValue()) + // Don't count transient instructions towards the search limit since there + // may be different numbers of them if e.g. debug information is present. + if (!MI.isTransient()) ++Count; // If the load instruction reads directly from the address to which the @@ -1229,13 +1230,11 @@ for (unsigned Count = 0; MBBI != E && Count < Limit; ++MBBI) { MachineInstr &MI = *MBBI; - // Skip DBG_VALUE instructions. Otherwise debug info can affect the - // optimization by changing how far we scan. - if (MI.isDebugValue()) - continue; - // Now that we know this is a real instruction, count it. - ++Count; + // Don't count transient instructions towards the search limit since there + // may be different numbers of them if e.g. debug information is present. + if (!MI.isTransient()) + ++Count; Flags.setSExtIdx(-1); if (areCandidatesToMergeOrPair(FirstMI, MI, Flags, TII) && @@ -1502,12 +1501,11 @@ ++MBBI; for (unsigned Count = 0; MBBI != E && Count < Limit; ++MBBI) { MachineInstr &MI = *MBBI; - // Skip DBG_VALUE instructions. - if (MI.isDebugValue()) - continue; - // Now that we know this is a real instruction, count it. - ++Count; + // Don't count transient instructions towards the search limit since there + // may be different numbers of them if e.g. debug information is present. + if (!MI.isTransient()) + ++Count; // If we found a match, return it. if (isMatchingUpdateInsn(*I, MI, BaseReg, UnscaledOffset)) @@ -1556,8 +1554,9 @@ --MBBI; MachineInstr &MI = *MBBI; - // Don't count DBG_VALUE instructions towards the search limit. - if (!MI.isDebugValue()) + // Don't count transient instructions towards the search limit since there + // may be different numbers of them if e.g. debug information is present. + if (!MI.isTransient()) ++Count; // If we found a match, return it.