Skip to content

Commit fa50248

Browse files
y1yang0randall77
authored andcommitted
cmd/compile: sparse conditional constant propagation
sparse conditional constant propagation can discover optimization opportunities that cannot be found by just combining constant folding and constant propagation and dead code elimination separately. Updates #59399 Change-Id: Ia954e906480654a6f0cc065d75b5912f96f36b2e GitHub-Last-Rev: 90fc02d GitHub-Pull-Request: #59575 Reviewed-on: https://go-review.googlesource.com/c/go/+/483875 Reviewed-by: Keith Randall <[email protected]> Reviewed-by: Keith Randall <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Michael Pratt <[email protected]> Run-TryBot: Keith Randall <[email protected]>
1 parent e7a9ca0 commit fa50248

File tree

8 files changed

+713
-20
lines changed

8 files changed

+713
-20
lines changed

src/cmd/compile/internal/ssa/_gen/genericOps.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,8 @@ var genericOps = []opData{
643643
// Plain [] [next]
644644
// If [boolean Value] [then, else]
645645
// First [] [always, never]
646+
// Defer [mem] [nopanic, panic] (control opcode should be OpStaticCall to runtime.deferproc)
647+
//JumpTable [integer Value] [succ1,succ2,..]
646648

647649
var genericBlocks = []blockData{
648650
{name: "Plain"}, // a single successor

src/cmd/compile/internal/ssa/block.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,6 @@ func (e Edge) String() string {
112112
}
113113

114114
// BlockKind is the kind of SSA block.
115-
//
116-
// kind controls successors
117-
// ------------------------------------------
118-
// Exit [return mem] []
119-
// Plain [] [next]
120-
// If [boolean Value] [then, else]
121-
// Defer [mem] [nopanic, panic] (control opcode should be OpStaticCall to runtime.deferproc)
122115
type BlockKind int16
123116

124117
// short form print
@@ -275,8 +268,7 @@ func (b *Block) truncateValues(i int) {
275268
b.Values = b.Values[:i]
276269
}
277270

278-
// AddEdgeTo adds an edge from block b to block c. Used during building of the
279-
// SSA graph; do not use on an already-completed SSA graph.
271+
// AddEdgeTo adds an edge from block b to block c.
280272
func (b *Block) AddEdgeTo(c *Block) {
281273
i := len(b.Succs)
282274
j := len(c.Preds)

src/cmd/compile/internal/ssa/compile.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ var passes = [...]pass{
477477
{name: "softfloat", fn: softfloat, required: true},
478478
{name: "late opt", fn: opt, required: true}, // TODO: split required rules and optimizing rules
479479
{name: "dead auto elim", fn: elimDeadAutosGeneric},
480+
{name: "sccp", fn: sccp},
480481
{name: "generic deadcode", fn: deadcode, required: true}, // remove dead stores, which otherwise mess up store chain
481482
{name: "check bce", fn: checkbce},
482483
{name: "branchelim", fn: branchelim},

0 commit comments

Comments
 (0)