The regalloc pass does that. It ensures that all the inputs and the output of a phi are all in the same register (or memory location), so the phi becomes a no-op.
The regalloc pass doesn't actually remove the phi, though. Removal is actually in genssa in cmd/compile/internal/gc/ssa.go. Look for CheckLoweredPhi, which makes sure that the above statement is actually correct for all phis.