Skip to content

Commit

Permalink
cmd/compile: call phiElimValue from removePhiArg
Browse files Browse the repository at this point in the history
With the exception of the shortcircuit pass, removePhiArg is always unconditionally followed by phiElimValue.
Move the phiElimValue inside removePhiArg.

Resolves a TODO.

See CL 357964 for more info.

Change-Id: I8460b35864f4cd7301ba86fc3dce08ec8041da7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/465435
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Jakub Ciolek <jakub@ciolek.dev>
  • Loading branch information
jake-ciolek authored and randall77 committed May 16, 2023
1 parent 51fe706 commit d29dd2e
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/cmd/compile/internal/ssa/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ func (b *Block) swapSuccessors() {
// if v.Op != OpPhi {
// continue
// }
// b.removeArg(v, i)
// b.removePhiArg(v, i)
//
// }
func (b *Block) removePhiArg(phi *Value, i int) {
Expand All @@ -353,6 +353,7 @@ func (b *Block) removePhiArg(phi *Value, i int) {
phi.Args[i] = phi.Args[n]
phi.Args[n] = nil
phi.Args = phi.Args[:n]
phielimValue(phi)
}

// LackingPos indicates whether b is a block whose position should be inherited
Expand Down
5 changes: 0 additions & 5 deletions src/cmd/compile/internal/ssa/critical.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ func critical(f *Func) {

// splitting occasionally leads to a phi having
// a single argument (occurs with -N)
// TODO(cuonglm,khr): replace this with phielimValue, and
// make removePhiArg incorporates that.
if len(b.Preds) == 1 {
phi.Op = OpCopy
}
// Don't increment i in this case because we moved
// an unprocessed predecessor down into slot i.
} else {
Expand Down
1 change: 0 additions & 1 deletion src/cmd/compile/internal/ssa/deadcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ func (b *Block) removeEdge(i int) {
continue
}
c.removePhiArg(v, j)
phielimValue(v)
// Note: this is trickier than it looks. Replacing
// a Phi with a Copy can in general cause problems because
// Phi and Copy don't have exactly the same semantics.
Expand Down
1 change: 0 additions & 1 deletion src/cmd/compile/internal/ssa/fuse_branchredirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func fuseBranchRedirect(f *Func) bool {
continue
}
b.removePhiArg(v, k)
phielimValue(v)
}
// Fix up child to have one more predecessor.
child.Preds = append(child.Preds, Edge{p, pk.i})
Expand Down

0 comments on commit d29dd2e

Please sign in to comment.