nir, spirv: miscellaneous fixes for nir_discard
Since !27617 isn't really going to fly, this is a subset of the patches plus one small workaround which will make it easier for drivers to emit demote by default. The workaround isn't particularly useful for anything but the two mentioned test cases, but it doesn't hurt anything either.
!28746 (6a1d06f9) still needs a review.