This is a bit trickier than register operands, and we still want to fall
back on a register operands even for things that appear to be
"immediates" when they won't actually select into the operation's
immediate operand. This also requires us to handle things like selecting
sub vs. add to minimize the number of bits needed to represent the
immediate, and picking the shortest immediate encoding.
The end result seems very nice though, and we're now generating
optimal instruction sequences for these patterns IMO.
A follow-up patch will further expand this to other operations with RMW
memory operands. But handing add and sub are useful starting points
to flesh out the machinery and make sure interesting and complex cases
can be handled.
Depends on D37130.
Should we just check the uses of ResNo(1)?