When performing memory folding (thus changing the register form of an instruction to it's memory form), make sure the register classes of the machine operands of the replaced instruction comply to the constrains of the register classes of the new instruction - If not, change them.
@craig.topper, i encountered this issue by coincidence but could not find a test case which fails without this. all the folded instructions right now have the same register classes constrains for both register and memory forms.
But as we entirely replace the instruction I saw that this change should be added even though it doesn't effect anything right now. Maybe it will be needed in the future.