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: arithmeticize memory loads statically known to only touch the .rodata section #70956

Open
Jorropo opened this issue Dec 22, 2024 · 0 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance

Comments

@Jorropo
Copy link
Member

Jorropo commented Dec 22, 2024

While doing https://go-review.googlesource.com/c/go/+/637936/3 I tested it on some code of mine and it failed to mark many of my functions pure because one callgraph leaf use a const string as a LUT.
This would also allow the compiler to reorder theses loads with stores which could help regalloc among other things.

For an example I made up this very simple function:

func hexDigit(x uint8) rune {
	return rune("0123456789abcdef"[x & 0b1111])
}

You can see that the Load op takes memory as an argument when this is not needed.
image

In this context we should model [] as an odd arithmetic operator by removing it's memory argument.

Chances I'll come back to this at some point.

@Jorropo Jorropo added Performance NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. compiler/runtime Issues related to the Go compiler and/or runtime. labels Dec 22, 2024
@Jorropo Jorropo changed the title cmd/compile: arithmeticize memory loads provably only from the .rodata segment cmd/compile: arithmeticize memory loads statically known to only touch the .rodata segment Dec 22, 2024
@Jorropo Jorropo changed the title cmd/compile: arithmeticize memory loads statically known to only touch the .rodata segment cmd/compile: arithmeticize memory loads statically known to only touch the .rodata section Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. 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

1 participant