3 ms·
From a quick look at the repository it looks like there are optimizations performed: this code[1] seems to perform function inlining at the AST level, this code
by Crinus 7y ago
From a quick look at the repository it looks like there are optimizations performed: this code[1] seems to perform function inlining at the AST level, this code[2] converts the AST to SSA form which is generally meant to be used for optimizations, the SSA directory[3] contains a bunch of optimizations like common subexpression elimination[4], deadcode elimination[5], useless branch elimination[6] and other stuff (just browse around the files, they have comments about what they do). The SSA seems to contain both generic and machine-specific opcodes (basically instructions for the latter) with the former being converted to the latter using a bunch of rule tables[7] which seem to contain both generic-to-native transforms as well as peephole optimization rules (these are converted to go source code, most likely the huge files in the parent directory). Finally there seem to be a few optimizations in the machine-specific code generator (e.g. [8]).
Of course it really depends on your definition of "meaningful", but i think that as long as it isn't equal to "as many optimizations known to humankind as possible, everything else be damned", the compiler looks to perform a decent amount of them. At least for me it passes the subjectively vague "meaningful" check :-P.
[1] https://github.com/golang/go/blob/master/src/cmd/compile/internal/gc/inl.go https://github.com/golang/go/blob/master/src/cmd/compile/int...
[2] https://github.com/golang/go/blob/master/src/cmd/compile/internal/gc/ssa.go https://github.com/golang/go/blob/master/src/cmd/compile/int...
[3] https://github.com/golang/go/tree/master/src/cmd/compile/internal/ssa https://github.com/golang/go/tree/master/src/cmd/compile/int...
[4] https://github.com/golang/go/blob/master/src/cmd/compile/internal/ssa/cse.go https://github.com/golang/go/blob/master/src/cmd/compile/int... https://github.com/golang/go/blob/master/src/cmd/compile/internal/ssa/zcse.go https://github.com/golang/go/blob/master/src/cmd/compile/int...
[5] https://github.com/golang/go/blob/master/src/cmd/compile/internal/ssa/deadcode.go https://github.com/golang/go/blob/master/src/cmd/compile/int...
[6] https://github.com/golang/go/blob/master/src/cmd/compile/internal/ssa/fuse.go https://github.com/golang/go/blob/master/src/cmd/compile/int...
[7] https://github.com/golang/go/tree/master/src/cmd/compile/internal/ssa/gen https://github.com/golang/go/tree/master/src/cmd/compile/int...
[8] https://github.com/golang/go/blob/master/src/cmd/compile/internal/amd64/ssa.go#L413 https://github.com/golang/go/blob/master/src/cmd/compile/int...