Skip to content

cmd/compile: improve generated type equality code #9930

@josharian

Description

@josharian

geneq generates a series of if statements, each returning false if they fail. Creating instead a long conjunction would result in shorter, faster generated code.

It might also be worth reordering the tests to place all the ones involving a function call last.

It might also be worth trying to prevent some of the spurious checknils that are currently produced. In some cases know that we are dereferencing fields on a struct (not a pointer to a struct).

We also appear to be generating equality routines when we shouldn't be. The following strike me as possibly spurious:

  • TEXT type..eq.[0]text/tabwriter.cell(SB) text/tabwriter/tabwriter.go. An array of length zero? Where does it come from? And the equality check should be trivial, not generated.
  • TEXT type..eq.[2]string(SB) golang.org/x/tools/cmd/godoc/blog.go. I don't see anything resembling [2]string in blog.go.
  • TEXT type..eq.[1]interface {}(SB) golang.org/x/tools/cmd/godoc/blog.go. I don't see where this came from in blog.go. And an equality check for an array of length 1 should just be a check of the underlying type.

Look into these.

Given all the above, it might be worth also taking a closer look at the generated hash routines as well.

I'll poke at these once the c2go conversion is complete.

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions