[llvm] [M68k] Prevent COPY instruction from killing live condition flags (PR #168485)

Dan Salvato via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 4 11:51:23 PDT 2026


dansalvato wrote:

> If there's really no way to copy a register without clobbering flags though that's quite sad...

There are technically two ways of doing it, but they have their own problems.

```m68k
    movem.w d0,-(sp)
    movem.w (sp)+,d1
```

```m68k
    exg     d1,a0
    movea.w d0,a0
    exg     d1,a0
```

Both of these share the same problem: They can't copy a byte (only a word or a longword), and they get sign-extended to longword on copy.

Theoretically, that *might* not be a problem, since if LLVM is trying to copy a byte- or word-sized register, then it likely implies that the upper bytes of the destination register are currently dead anyway. But I don't know if we want to just make that assumption.

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


More information about the llvm-commits mailing list