[dev.ssa] cmd/compile: make cse faster

It is one of the slowest compiler phases right now, and we
run two of them.

Instead of using a map to make the initial partition, use a sort.
It is much less memory intensive.

Do a few optimizations to avoid work for size-1 equivalence classes.

Implement -N.

Change-Id: I1d2d85d3771abc918db4dd7cc30b0b2d854b15e1
Reviewed-on: https://go-review.googlesource.com/19024
Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
Keith Randall 2016-01-27 16:47:23 -08:00
parent 7b773946c0
commit 6a96a2fe5a
10 changed files with 206 additions and 276 deletions

View file

@ -316,6 +316,12 @@ func (s *regAllocState) assignReg(r register, v *Value, c *Value) {
fmt.Printf("assignReg %s %s/%s\n", registers[r].Name(), v, c)
}
if s.regs[r].v != nil {
if v.Op == OpSB && !v.Block.Func.Config.optimize {
// Rewrite rules may introduce multiple OpSB, and with
// -N they don't get CSEd. Ignore the extra assignments.
s.f.setHome(c, &registers[r])
return
}
s.f.Fatalf("tried to assign register %d to %s/%s but it is already used by %s", r, v, c, s.regs[r].v)
}