[SDAG] Simplify the code for handling single-value nodes and add
a missing transfer of debug information (without which tests fail).
[SDAG] Add an assert that we don't mess up the number of values when
replacing nodes in the legalizer.

This caught a number of bugs for me during development.