The previous expansion used SBCI, which is incorrect because the NEGW pseudo instruction accepts a DREGS operand (2xGPR8) and SBCI only allows LD8 registers. One solution could be to correct the NEGW pseudo instruction, but another solution is to use a different instruction (sbc) that does accept a GPR8 register and therefore allows more freedom to the register allocator.
The output now matches avr-gcc for the following code:
int foo(int n) { return -n; }
I've found this issue using the machine instruction verifier: it was complaining about the wrong register class in NEGWRd.mir.
this line needs to be deleted, otherwise there might be a crash ?