Something went wrong. Try again.
🌱 A minimal programming language and compiler. git.urbach.dev/cli/q
high-performance programming-language compiler
Something went wrong. Try again.
123456789101112131415package optimizer
import "git.urbach.dev/cli/q/src/ssa"
// foldTo replaces a binary operation with another value.func foldTo(ir ssa.IR, binaryOp *ssa.BinaryOp, value ssa.Value, discarded ssa.Value, folded map[ssa.Value]struct{}) map[ssa.Value]struct{} { if folded == nil { folded = make(map[ssa.Value]struct{}) }
folded[binaryOp] = struct{}{} folded[discarded] = struct{}{} ir.ReplaceAll(binaryOp, value) return folded}