Skip to content

Commit 3383b28

Browse files
committed
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
1 parent 5f1a032 commit 3383b28

File tree

4 files changed

+458
-7
lines changed

4 files changed

+458
-7
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 [boolean Value] [succ1,succ2,..]
646648

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

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

Lines changed: 0 additions & 7 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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ var passes = [...]pass{
459459
{name: "number lines", fn: numberLines, required: true},
460460
{name: "early phielim", fn: phielim},
461461
{name: "early copyelim", fn: copyelim},
462+
{name: "sccp", fn: sccp},
462463
{name: "early deadcode", fn: deadcode}, // remove generated dead code to avoid doing pointless work during opt
463464
{name: "short circuit", fn: shortcircuit},
464465
{name: "decompose user", fn: decomposeUser, required: true},

0 commit comments

Comments
 (0)