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

Open
Jorropo opened this issue Dec 22, 2024 · 1 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
Milestone

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
@mknyszek mknyszek added this to the Unplanned milestone Jan 15, 2025
@mknyszek mknyszek changed the title cmd/compile: arithmeticize memory loads statically known to only touch the .rodata section cmd/compile: compile-time-evaluate memory loads statically known to only touch the .rodata section Jan 15, 2025
@Jorropo Jorropo changed the title cmd/compile: compile-time-evaluate memory loads statically known to only touch the .rodata section cmd/compile: remove memory components for loads statically known to only touch the .rodata section Jan 31, 2025
@Jorropo
Copy link
Member Author

Jorropo commented Jan 31, 2025

I've changed the title again.
I think compile time evaluating them would also be a good thing but it's not what I had in mind.

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
Development

No branches or pull requests

2 participants