[llvm] [AArch64] Treat NOP as a separate instruction. (PR #170968)

Harald van Dijk via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 8 09:04:41 PST 2025


hvdijk wrote:

> We usually don't generate these for codegen (usually we use alignment directives instead).

Usually, but there are exceptions, such as `AArch64A53Fix835769.cpp` (updated by this PR) where `nop` gets inserted between instruction sequences that happen to trigger a CPU bug, when the workaround is enabled.

> If we were adding them, and the instruction had no side-effects and no inputs/outputs, what is to stop it from being removed? It looks like it is only the late positions in the pipelines of the current uses that is preventing it?

Yes, and I think that is correct. If you're still early enough in the pipeline that you're running passes like `DeadMachineInstructionElim` that remove instructions that do nothing, you'd want this instruction that does nothing to be removed. [The X86 `nop` instructions](https://github.com/llvm/llvm-project/blob/f27fbca37c4a66d4e237bae1256d775ca7471cb9/llvm/lib/Target/X86/X86InstrMisc.td#L17-L33) are already marked `hasSideEffects = 0` too, as is [the RISC-V `nop`](https://github.com/llvm/llvm-project/blob/f27fbca37c4a66d4e237bae1256d775ca7471cb9/llvm/lib/Target/RISCV/RISCVInstrInfo.td#L1050) which is defined as an alias for a form of `addi`, which also is marked `hasSideEffects = 0`.

https://github.com/llvm/llvm-project/pull/170968


More information about the llvm-commits mailing list