[dev.ssa] cmd/compile/internal/ssa: transform degenerate control blocks
* In cases where we end up with empty branches like in if a then jmp b else jmp b; the flow can be replaced by a; jmp b. The following functions is optimized as follows: func f(a bool, x int) int { v := 0 if a { v = -1 } else { v = -1 } return x | v } Before this change: 02819 (arith_ssa.go:362) VARDEF "".~r2+16(FP) 02820 (arith_ssa.go:362) MOVQ $0, "".~r2+16(FP) 02821 (arith_ssa.go:362) MOVB "".a(FP), AX 02822 (arith_ssa.go:362) TESTB AX, AX 02823 (arith_ssa.go:364) JEQ 2824 02824 (arith_ssa.go:369) VARDEF "".~r2+16(FP) 02825 (arith_ssa.go:369) MOVQ $-1, "".~r2+16(FP) 02826 (arith_ssa.go:369) RET After this change: 02819 (arith_ssa.go:362) VARDEF "".~r2+16(FP) 02820 (arith_ssa.go:369) VARDEF "".~r2+16(FP) 02821 (arith_ssa.go:369) MOVQ $-1, "".~r2+16(FP) 02822 (arith_ssa.go:369) RET Updates #14277 Change-Id: Ibe7d284f43406c704903632a4fcf2a4a64059686 Reviewed-on: https://go-review.googlesource.com/19464Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro> TryBot-Result: Gobot Gobot <gobot@golang.org>
Showing
Please
register
or
sign in
to comment