Skip to content

Commit 4ee1d54

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. This is a re-submit of PR#59575, which fix a broken dominance relationship caught by ssacheck Updates #59399 Change-Id: I57482dee38f8e80a610aed4f64295e60c38b7a47 GitHub-Last-Rev: 830016f GitHub-Pull-Request: #60469 Reviewed-on: https://go-review.googlesource.com/c/go/+/498795 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Keith Randall <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent a843991 commit 4ee1d54

File tree

8 files changed

+711
-16
lines changed

8 files changed

+711
-16
lines changed

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

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

653655
var genericBlocks = []blockData{
654656
{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)