[llvm] [AArch64] Reland merge index address with large offset into base address (PR #79951)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 30 05:54:23 PST 2024
================
@@ -2213,6 +2213,9 @@ bool AArch64LoadStoreOpt::isMatchingMovConstInsn(MachineInstr &MemMI,
// movz + movk hold a large offset of a Ld/St instruction.
MachineBasicBlock::iterator B = MI.getParent()->begin();
MachineBasicBlock::iterator MBBI = &MI;
+ // Skip the scene when the MI is the first instruction of a block.
+ if (MBBI == B)
+ return false;
MBBI = prev_nodbg(MBBI, B);
----------------
vfdff wrote:
It will return the **Begin instrunction** when there is a single previous dbg instruction, .ie **it will return normal**.
```
/// Decrement \p It until it points to a non-debug instruction or to \p Begin
/// and return the resulting iterator. This function should only be used
/// MachineBasicBlock::{iterator, const_iterator, instr_iterator,
/// const_instr_iterator} and the respective reverse iterators.
template <class IterT>
inline IterT skipDebugInstructionsBackward(IterT It, IterT Begin,
bool SkipPseudoOp = true) {
while (It != Begin &&
(It->isDebugInstr() || (SkipPseudoOp && It->isPseudoProbe())))
--It;
return It;
}
/// Decrement \p It, then continue decrementing it while it points to a debug
/// instruction. A replacement for std::prev.
template <typename IterT>
inline IterT prev_nodbg(IterT It, IterT Begin, bool SkipPseudoOp = true) {
return skipDebugInstructionsBackward(std::prev(It), Begin, SkipPseudoOp);
}
```
https://github.com/llvm/llvm-project/pull/79951
More information about the llvm-commits
mailing list