]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.ssa] cmd/compile: fix registers for in-place instructions
authorJosh Bleecher Snyder <josharian@gmail.com>
Sat, 25 Jul 2015 03:09:39 +0000 (20:09 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Mon, 27 Jul 2015 17:24:54 +0000 (17:24 +0000)
Some of these were right; others weren't.

Fixes 'GOGC=off GOSSAPKG=mime go test -a mime'.

The right long term fix is probably to teach the
register allocator about in-place instructions.
In the meantime, all the tests that we can run
now pass.

Change-Id: I8e37b00a5f5e14f241b427d45d5f5cc1064883a2
Reviewed-on: https://go-review.googlesource.com/12664
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/ssa/TODO

index 7a3396482f3ee337ddcc642ed731037d3011faf9..32d42d82648fa845e77b8da9e48cf297fe69cc93 100644 (file)
@@ -1492,7 +1492,7 @@ func genValue(v *ssa.Value) {
                p.From.Reg = regnum(v.Args[1]) // should be CX
                p.To.Type = obj.TYPE_REG
                p.To.Reg = r
-       case ssa.OpAMD64SHLQconst, ssa.OpAMD64SHRQconst, ssa.OpAMD64SARQconst:
+       case ssa.OpAMD64SHLQconst, ssa.OpAMD64SHRQconst, ssa.OpAMD64SARQconst, ssa.OpAMD64XORQconst:
                x := regnum(v.Args[0])
                r := regnum(v)
                if x != r {
@@ -1686,12 +1686,6 @@ func genValue(v *ssa.Value) {
                p := Prog(obj.ACALL)
                p.To.Type = obj.TYPE_REG
                p.To.Reg = regnum(v.Args[0])
-       case ssa.OpAMD64XORQconst:
-               p := Prog(x86.AXORQ)
-               p.From.Type = obj.TYPE_CONST
-               p.From.Offset = v.AuxInt
-               p.To.Type = obj.TYPE_REG
-               p.To.Reg = regnum(v.Args[0])
        case ssa.OpAMD64NEGQ, ssa.OpAMD64NEGL, ssa.OpAMD64NEGW, ssa.OpAMD64NEGB:
                p := Prog(v.Op.Asm())
                p.To.Type = obj.TYPE_REG
index 225768c73c917e151ce9460827390a6e78a03059..f77c5ad8f3359f694ec4c42b9c827570895edd1e 100644 (file)
@@ -28,6 +28,8 @@ Regalloc
  - Floating point registers
  - Make calls clobber all registers
  - Make liveness analysis non-quadratic.
+ - Handle in-place instructions (like XORQconst) directly:
+   Use XORQ AX, 1 rather than MOVQ AX, BX; XORQ BX, 1.
 
 StackAlloc:
  - Sort variables so all ptr-containing ones are first (so stack