Commit 18b48afe authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: mark MOVQconvert as resultInArg0 on x86 architectures

This prevents unnecessary reg-reg moves during pointer arithmetic.

This change reduces the size of the full hello world binary by 0.4%.

Updates #21572

Change-Id: Ia0427021e5c94545a0dbd83a6801815806e5b12d
Reviewed-on: https://go-review.googlesource.com/58371
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
Reviewed-by: default avatarKeith Randall <khr@golang.org>
parent 83ae9b07
...@@ -448,7 +448,7 @@ func init() { ...@@ -448,7 +448,7 @@ func init() {
// (particularly stack maps). It takes a memory arg so it // (particularly stack maps). It takes a memory arg so it
// gets correctly ordered with respect to GC safepoints. // gets correctly ordered with respect to GC safepoints.
// arg0=ptr/int arg1=mem, output=int/ptr // arg0=ptr/int arg1=mem, output=int/ptr
{name: "MOVLconvert", argLength: 2, reg: gp11, asm: "MOVL"}, {name: "MOVLconvert", argLength: 2, reg: gp11, asm: "MOVL", resultInArg0: true},
// Constant flag values. For any comparison, there are 5 possible // Constant flag values. For any comparison, there are 5 possible
// outcomes: the three from the signed total order (<,==,>) and the // outcomes: the three from the signed total order (<,==,>) and the
......
...@@ -538,8 +538,8 @@ func init() { ...@@ -538,8 +538,8 @@ func init() {
// (particularly stack maps). It takes a memory arg so it // (particularly stack maps). It takes a memory arg so it
// gets correctly ordered with respect to GC safepoints. // gets correctly ordered with respect to GC safepoints.
// arg0=ptr/int arg1=mem, output=int/ptr // arg0=ptr/int arg1=mem, output=int/ptr
{name: "MOVQconvert", argLength: 2, reg: gp11, asm: "MOVQ"}, {name: "MOVQconvert", argLength: 2, reg: gp11, asm: "MOVQ", resultInArg0: true},
{name: "MOVLconvert", argLength: 2, reg: gp11, asm: "MOVL"}, // amd64p32 equivalent {name: "MOVLconvert", argLength: 2, reg: gp11, asm: "MOVL", resultInArg0: true}, // amd64p32 equivalent
// Constant flag values. For any comparison, there are 5 possible // Constant flag values. For any comparison, there are 5 possible
// outcomes: the three from the signed total order (<,==,>) and the // outcomes: the three from the signed total order (<,==,>) and the
......
...@@ -177,10 +177,10 @@ func genOp() { ...@@ -177,10 +177,10 @@ func genOp() {
if v.resultInArg0 { if v.resultInArg0 {
fmt.Fprintln(w, "resultInArg0: true,") fmt.Fprintln(w, "resultInArg0: true,")
if v.reg.inputs[0] != v.reg.outputs[0] { if v.reg.inputs[0] != v.reg.outputs[0] {
log.Fatalf("input[0] and output[0] must use the same registers for %s", v.name) log.Fatalf("%s: input[0] and output[0] must use the same registers for %s", a.name, v.name)
} }
if v.commutative && v.reg.inputs[1] != v.reg.outputs[0] { if v.commutative && v.reg.inputs[1] != v.reg.outputs[0] {
log.Fatalf("input[1] and output[0] must use the same registers for %s", v.name) log.Fatalf("%s: input[1] and output[0] must use the same registers for %s", a.name, v.name)
} }
} }
if v.resultNotInArgs { if v.resultNotInArgs {
......
...@@ -4273,6 +4273,7 @@ var opcodeTable = [...]opInfo{ ...@@ -4273,6 +4273,7 @@ var opcodeTable = [...]opInfo{
{ {
name: "MOVLconvert", name: "MOVLconvert",
argLen: 2, argLen: 2,
resultInArg0: true,
asm: x86.AMOVL, asm: x86.AMOVL,
reg: regInfo{ reg: regInfo{
inputs: []inputInfo{ inputs: []inputInfo{
...@@ -7822,6 +7823,7 @@ var opcodeTable = [...]opInfo{ ...@@ -7822,6 +7823,7 @@ var opcodeTable = [...]opInfo{
{ {
name: "MOVQconvert", name: "MOVQconvert",
argLen: 2, argLen: 2,
resultInArg0: true,
asm: x86.AMOVQ, asm: x86.AMOVQ,
reg: regInfo{ reg: regInfo{
inputs: []inputInfo{ inputs: []inputInfo{
...@@ -7835,6 +7837,7 @@ var opcodeTable = [...]opInfo{ ...@@ -7835,6 +7837,7 @@ var opcodeTable = [...]opInfo{
{ {
name: "MOVLconvert", name: "MOVLconvert",
argLen: 2, argLen: 2,
resultInArg0: true,
asm: x86.AMOVL, asm: x86.AMOVL,
reg: regInfo{ reg: regInfo{
inputs: []inputInfo{ inputs: []inputInfo{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment