Skip to content
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

cmd/compile: optimize with CMN/TST/TEQ #21583

benshi001 opened this issue Aug 24, 2017 · 1 comment

cmd/compile: optimize with CMN/TST/TEQ #21583

benshi001 opened this issue Aug 24, 2017 · 1 comment


Copy link

@benshi001 benshi001 commented Aug 24, 2017

The following go function

func ss(u, q uint32) uint32 {
        if u & q == 0 {
                return 2
        if u + q == 0  {
                return 3
        if q ^ u == 0 {
                return 9
        return 1

is compiled to

  a.go:7                0x9ca50                 e0002001                AND R1, R0, R2
  a.go:7                0x9ca54                 e3520000                CMP $0, R2
  a.go:7                0x9ca58                 0a00000e                B.EQ 0x9ca98
  a.go:10               0x9ca5c                 e0802001                ADD R1, R0, R2
  a.go:10               0x9ca60                 e3520000                CMP $0, R2
  a.go:10               0x9ca64                 0a000008                B.EQ 0x9ca8c
  a.go:13               0x9ca68                 e0210000                EOR R0, R1, R0
  a.go:13               0x9ca6c                 e3500000                CMP $0, R0
  a.go:13               0x9ca70                 1a000002                B.NE 0x9ca80

But can be optimized to

CMN	R1, R0, R2
B.EQ	xxx
TST	R1, R0, R2
TEQ	R0, R1, r2
B.NE	xxx

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Oct 2, 2017

Change mentions this issue: cmd/compile: optimize ARM code with CMN/TST/TEQ

@gopherbot gopherbot closed this in 1ec78d1 Oct 11, 2017
@golang golang locked and limited conversation to collaborators Oct 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.