-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: redundant jumps #14277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Milestone
Comments
CC @randall77 |
CL https://golang.org/cl/19414 mentions this issue. |
CL https://golang.org/cl/19464 mentions this issue. |
gopherbot
pushed a commit
that referenced
this issue
Feb 17, 2016
* 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/19464 Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro> TryBot-Result: Gobot Gobot <gobot@golang.org>
Not closing because a few cases are not handled yet. I'm looking for more examples. |
Fixed now. The generated code looks very nice:
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
dev.ssa: The following code
results in a lot of redundant jumps. After the trim pass:
and the code generated
For example JEQ 92 branch cannot be taken.
The text was updated successfully, but these errors were encountered: