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

Closed
benshi001 opened this issue Aug 24, 2017 · 1 comment
Closed

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

benshi001 opened this issue Aug 24, 2017 · 1 comment

Comments

@benshi001
Copy link
Member

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
B.EQ	XXX
TEQ	R0, R1, r2
B.NE	xxx
@gopherbot
Copy link

Change https://golang.org/cl/67490 mentions this issue: cmd/compile: optimize ARM code with CMN/TST/TEQ

@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.
Projects
None yet
Development

No branches or pull requests

2 participants