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: triple negation on arm64 #48467

Closed
greatroar opened this issue Sep 19, 2021 · 1 comment
Closed

cmd/compile: triple negation on arm64 #48467

greatroar opened this issue Sep 19, 2021 · 1 comment
Labels
arch-arm64 FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance

Comments

@greatroar
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.17.1 linux/amd64

Does this issue reproduce with the latest release?

Reproduces with

$ gotip version
go version devel go1.18-771b8ea4f4c Sun Sep 19 02:43:09 2021 +0000 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH=arm64

What did you do?

// Branchless max.
func max(x, y uint) uint {
	d, borrow := bits.Sub(x, y, 0)
	return x - d&(-borrow)
}

What did you expect to see?

SUBS	R1, R0, R1
NGC	ZR, R2
AND	R2, R1, R1
SUB	R1, R0, R0

What did you see instead?

SUBS	R1, R0, R1
NGC	ZR, R2
NEG	R2, R2
NEG	R2, R2
AND	R2, R1, R1
SUB	R1, R0, R0

Looks like the rule that eliminates double negation fires too early.

@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 19, 2021
@ALTree ALTree changed the title Compiler produces triple negation on arm64 cmd/compile: triple negation on arm64 Sep 19, 2021
@gopherbot
Copy link

Change https://golang.org/cl/350910 mentions this issue: cmd/compile: fold double negate on arm64

@golang golang locked and limited conversation to collaborators Sep 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-arm64 FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance
Projects
None yet
Development

No branches or pull requests

3 participants