nir: Add a store_reg helper and use the builder in phis_to_regs