Skip to content

cmd/compile: remove memory components for loads statically known to only touch the .rodata section #70956

@Jorropo

Description

@Jorropo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions