bbdd34b4ad
"Rewrite and remove" is a super common idiom in NIR passes. Let's add a helper to make it more ergonomic. More the point, I expect that /most/ of the time when a pass rewrites uses, they also want to remove the parent instruction. The principle reason not to is because it takes extra effort to add in the nir_instr_remove and nir_opt_dce will clean up after you eventually, right? From a compile time perspective, it's better to remove earlier to reduce the redundant processing between the pass and the next DCE run. So ... we want to be doing *more* removes. From a UX perspective - the way to nudge devs towards that is to make the preferred "rewrite-and-remove" pattern more ergonomic than the "rewrite but keep". That justifies the simple "replace" name rather than something silly like "rewrite_uses_and_remove". --- Something else I've wanted for a while. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29817>