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

// fuseEarly runs fuse(f, fuseTypePlain|fuseTypeIntInRange).
func fuseEarly(f *Func) {}

// fuseLate runs fuse(f, fuseTypePlain|fuseTypeIf|fuseTypeBranchRedirect).
func fuseLate(f *Func) {}

type fuseType

const fuseTypePlain

const fuseTypeIf

const fuseTypeIntInRange

const fuseTypeBranchRedirect

const fuseTypeShortCircuit

// fuse simplifies control flow by joining basic blocks.
func fuse(f *Func, typ fuseType) {}

// fuseBlockIf handles the following cases where s0 and s1 are empty blocks.
//
//	   b        b           b       b
//	\ / \ /    | \  /    \ / |     | |
//	 s0  s1    |  s1      s0 |     | |
//	  \ /      | /         \ |     | |
//	   ss      ss           ss      ss
//
// If all Phi ops in ss have identical variables for slots corresponding to
// s0, s1 and b then the branch can be dropped.
// This optimization often comes up in switch statements with multiple
// expressions in a case clause:
//
//	switch n {
//	  case 1,2,3: return 4
//	}
//
// TODO: If ss doesn't contain any OpPhis, are s0 and s1 dead code anyway.
func fuseBlockIf(b *Block) bool {}

// isEmpty reports whether b contains any live values.
// There may be false positives.
func isEmpty(b *Block) bool {}

// fuseBlockPlain handles a run of blocks with length >= 2,
// whose interior has single predecessors and successors,
// b must be BlockPlain, allowing it to be any node except the
// last (multiple successors means not BlockPlain).
// Cycles are handled and merged into b's successor.
func fuseBlockPlain(b *Block) bool {}