Some pipelined CPUs have retained compatibility with self-modifying code and detect when you overwrite an instruction that is on the pipeline and flush it.
X86 has that machinery although I'm not sure if they dropped it eventually on the 64-bit variant.