]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: call phiElimValue from removePhiArg
authorJakub Ciolek <jakub@ciolek.dev>
Mon, 6 Feb 2023 06:18:53 +0000 (07:18 +0100)
committerKeith Randall <khr@golang.org>
Tue, 16 May 2023 21:40:11 +0000 (21:40 +0000)
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>

src/cmd/compile/internal/ssa/block.go
src/cmd/compile/internal/ssa/critical.go
src/cmd/compile/internal/ssa/deadcode.go
src/cmd/compile/internal/ssa/fuse_branchredirect.go

index 9a1dc8e7d1216047800f39d2f8389f316761b358..e7776b231643c6c2d222b99a6b936ae1b0612b66 100644 (file)
@@ -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) {
@@ -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
index ddf1c0fa8915d6ae380464e44ed54649585212fc..f14bb93e6d324131b9b7a4c0c7e6d64614f8d8c7 100644 (file)
@@ -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 {
index bd4282ecdb63e48750922beb84c50b61edba30cf..52cc7f2ca74d8492ad832fe60f5a0bcc1de9c8c2 100644 (file)
@@ -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.
index 59570968a2751e9b6cdfaa9051d6442ffd862cfc..153c2a56b716b21eaaac2f37c50bb0fb249b2902 100644 (file)
@@ -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})