When we lower dynamic stack, we need to substract pattern x15 << 4 from sp.
Subtract instruction with arith shifted register(SUBXrs) can't refer to sp. So for now we need two extra mov like:
mov x0, sp sub x0, x0, x15, lsl #4 mov sp, x0
If we want to refer to sp in subtract instruction like this:
sub sp, sp, x15, lsl #4
We must use arith extended register version(SUBXrx).
So in this patch when we find sub have sp operand on src0, try to select to SubXrx64.
Please don't use getMachineNode outside of actual instruction selection (AArch64ISelDAGToDAG). It sort of works, but it breaks the relationship between the lowering and instruction selection, so it can have confusing effects. Instead, add an opcode to AArch64ISelLowering.h. (I know this hasn't been followed consistently in the past, but I'd prefer not to expand the existing usage.)