1
0
mirror of https://github.com/golang/go synced 2024-10-05 14:11:22 -06:00
Commit Graph

12 Commits

Author SHA1 Message Date
Russ Cox
92dba0d278 cmd/internal/gc: use hardware instruction for math.Sqrt (amd64/arm)
I first prototyped this change in Sept 2011, and I discarded it
because it made no difference in the obvious benchmark loop.
It still makes no difference in the obvious benchmark loop,
but in a less obvious one, doing some extra computation
around the calls to Sqrt, not making the call does have a
significant effect.

benchmark                 old ns/op     new ns/op     delta
BenchmarkSqrt             4.56          4.57          +0.22%
BenchmarkSqrtIndirect     4.56          4.56          +0.00%
BenchmarkSqrtGo           69.4          69.4          +0.00%
BenchmarkSqrtPrime        4417          3647          -17.43%

This is a warmup for using hardware expansions for some
calls to 1-line assembly routines in the runtime (for example getg).

Change-Id: Ie66be23f8c09d0f7dc4ddd7ca8a93cfce28f55a4
Reviewed-on: https://go-review.googlesource.com/8356
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-03 16:13:36 +00:00
Russ Cox
b115c35ee3 cmd/internal/gc: move cgen, regalloc, et al to portable code
This CL moves the bulk of the code that has been copy-and-pasted
since the initial 386 port back into a shared place, cutting 5 copies to 1.

The motivation here is not cleanup per se but instead to reduce the
cost of introducing changes in shared concepts like regalloc or general
expression evaluation. For example, a change after this one will
implement x.(*T) without a call into the runtime. This CL makes that
followup work 5x easier.

The single copy still has more special cases for architecture details
than I'd like, but having them called out explicitly like this at least
opens the door to generalizing the conditions and smoothing out
the distinctions in the future.

This is a LARGE CL. I started by trying to pull in one function at a time
in a sequence of CLs and it became clear that everything was so
interrelated that it had to be moved as a whole. Apologies for the size.

It is not clear how many more releases this code will matter for;
eventually it will be replaced by Keith's SSA work. But as noted above,
the deduplication was necessary to reduce the cost of working on
the current code while we have it.

Passes tests on amd64, 386, arm, and ppc64le.
Can build arm64 binaries but not tested there.
Being able to build binaries means it is probably very close.

Change-Id: I735977f04c0614f80215fb12966dfe9bbd1f5861
Reviewed-on: https://go-review.googlesource.com/7853
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-20 20:03:52 +00:00
Russ Cox
8b9a3d4752 cmd/internal/gc: change Naddr to take a *Addr to fill in
This allows gins to let Naddr fill in p.From and p.To directly,
avoiding the zeroing and copying of a temporary.

Change-Id: I96d120afe266e68f94d5e82b00886bf6bd458f85
Reviewed-on: https://go-review.googlesource.com/7742
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-03-20 00:02:52 +00:00
Michael Hudson-Doyle
6582d1cf8b cmd/internal/gc, etc: remove canemitecode of Naddr
The argument is never consulted apart from passing it to recursive
calls.  So delete it.

Change-Id: Ia15eefb6385b3c99ea4def88f564f4e5a94c68ab
Reviewed-on: https://go-review.googlesource.com/7032
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-13 22:56:42 +00:00
Russ Cox
5a16d6fc34 cmd/5g etc: tweak import blocks
Remove blank lines and merge lone imports into blocks.

Change-Id: Ib46dad584456909969f1ba3a2c7f5667abf336ae
Reviewed-on: https://go-review.googlesource.com/6792
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-03-05 02:02:34 +00:00
Russ Cox
4492811c05 cmd/internal/gc: manual goto removal + grind to move var decls
Also change gc.Naddr to return the Addr instead of filling it in.

Change-Id: I98a86705d23bee49626a12a042a4d51cabe290ea
Reviewed-on: https://go-review.googlesource.com/6601
Reviewed-by: Rob Pike <r@golang.org>
2015-03-03 20:33:57 +00:00
Russ Cox
175929b9fe cmd/5g etc: mechanical cleanup
Run rsc.io/grind rev 796d0f2 on C->Go conversions.

This replaces various awkward := initializations with plain var declarations.

Checked bit-for-bit compatibility with toolstash + buildall.

Change-Id: I601101d8177894adb9b0e3fb55dfe0ed4f544716
Reviewed-on: https://go-review.googlesource.com/6517
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-03 20:32:24 +00:00
Josh Bleecher Snyder
25da594c6a cmd/{5,6,8,9}g, cmd/internal/gc: use bools for is* and okfor*
No functional changes.

This diff was generated as follows:

* Manually edit cmd/internal/gc/go.go to update types and group variables.
* Manually edit initialization in cmd/internal/gc/align.go--localized s/1/true.
* Manually fix the handling of sign in cmd/internal/gc/walk.go in func bounded (near line 4000).
* Manually update go.y and regenerate y.go.
* Run gofmt -r many times to do the rest, using https://gist.github.com/josharian/0f61dbb2dff81f938e70.

toolstash -cmp on the stdlib comes back green.

Change-Id: I19766ed551714e51b325133e7138818d117b3a9a
Reviewed-on: https://go-review.googlesource.com/6530
Reviewed-by: Russ Cox <rsc@golang.org>
2015-03-03 07:11:18 +00:00
Russ Cox
79f727a70e cmd/5g etc: mechanical cleanup
Run rsc.io/grind rev a26569f on C->Go conversions.

The new change in grind is the inlining of goto targets.
If code says 'goto x' and the block starting at label x is unreachable
except through that goto and the code can be moved to where
the goto is without changing the meaning of its variable names,
grind does that move. Simlarly, a goto to a plain return statement
turns into that return statement (even if there are other paths to
the return statement).

Combined, these remove many long-distance gotos, which in turn
makes it possible to reduce the scope of more variable declarations.
(Because gotos can't jump across declarations, the gotos were
keeping the declarations from moving.)

Checked bit-for-bit compatibility with toolstash + buildall.

Reduces compiler runtime in html/template by about 12%.

Change-Id: Id727c0bd7763a61aa22f3daa00aeb8fccbc057a3
Reviewed-on: https://go-review.googlesource.com/6472
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-03-02 18:40:28 +00:00
Rob Pike
daddeb2686 cmd/internal/obj: make Rconv a global function
Clean up the obj API by making Rconv (register pretty printer) a top-level
function. This means that Dconv (operand pretty printer) doesn't need
an Rconv argument.

To do this, we make the register numbers, which are arbitrary inside an
operand (obj.Addr), disjoint sets for each architecture. Each architecture
registers (ha) a piece of the space and then the global Rconv knows which
architecture-specific printer to use.

Clean up all the code that uses Dconv.

Now register numbers are large, so a couple of fields in Addr need to go
from int8 to int16 because they sometimes hold register numbers. Clean
up their uses, which meant regenerating the yacc grammars for the
assemblers. There are changes in this CL triggered by earlier changes
to yacc, which had not been run in this directory.

There is still cleanup to do in Addr, but we're getting closer to that being
easy to do.

Change-Id: I9290ebee013b62f7d24e886743ea5a6b232990ab
Reviewed-on: https://go-review.googlesource.com/6220
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-27 03:51:33 +00:00
Russ Cox
382b44eb7c [dev.cc] cmd/5g etc: code cleanup: delay var decls and eliminate dead code
Ran rsc.io/grind rev 6f0e601 on the source files.

The cleanups move var declarations as close to the use
as possible, splitting disjoint uses of the var into separate
variables. They also remove dead code (especially in
func sudoaddable), which helps with the var moving.

There's more cleanup to come, but this alone cuts the
time spent compiling html/template on my 2013 MacBook Pro
from 3.1 seconds to 2.3 seconds.

Change-Id: I4de499f47b1dd47a560c310bbcde6b08d425cfd6
Reviewed-on: https://go-review.googlesource.com/5637
Reviewed-by: Rob Pike <r@golang.org>
2015-02-23 21:36:06 +00:00
Russ Cox
3af0d791be [dev.cc] cmd/6a, cmd/6g etc: replace C implementations with Go implementations
Change-Id: I58e00a39cf63df07813d21453f91e68eef6a413c
Reviewed-on: https://go-review.googlesource.com/5635
Reviewed-by: Rob Pike <r@golang.org>
2015-02-23 19:56:40 +00:00