1
0
mirror of https://github.com/golang/go synced 2024-11-18 11:55:01 -07:00

cmd/compile: fix optimization of Zero newobject on amd64p32

On amd64p32, PtrSize and RegSize don't agree, and function return
value is aligned with RegSize. Fix this rule. Other architectures
are not affected, where PtrSize and RegSize are the same.

Change-Id: If187d3dfde3dc3b931b8e97db5eeff49a781551b
Reviewed-on: https://go-review.googlesource.com/37720
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Cherry Zhang 2017-03-03 13:53:13 -05:00
parent d8a0f74801
commit 9b480521d8
2 changed files with 4 additions and 4 deletions

View File

@ -1388,7 +1388,7 @@
(Zero (Load (OffPtr [c] (SP)) mem) mem)
&& mem.Op == OpStaticCall
&& isSameSym(mem.Aux, "runtime.newobject")
&& c == config.ctxt.FixedFrameSize() + config.PtrSize // offset of return value
&& c == config.ctxt.FixedFrameSize() + config.RegSize // offset of return value
-> mem
// nil checks just need to rewrite to something useless.
// they will be deadcode eliminated soon afterwards.

View File

@ -17210,7 +17210,7 @@ func rewriteValuegeneric_OpZero(v *Value, config *Config) bool {
b := v.Block
_ = b
// match: (Zero (Load (OffPtr [c] (SP)) mem) mem)
// cond: mem.Op == OpStaticCall && isSameSym(mem.Aux, "runtime.newobject") && c == config.ctxt.FixedFrameSize() + config.PtrSize
// cond: mem.Op == OpStaticCall && isSameSym(mem.Aux, "runtime.newobject") && c == config.ctxt.FixedFrameSize() + config.RegSize
// result: mem
for {
v_0 := v.Args[0]
@ -17230,7 +17230,7 @@ func rewriteValuegeneric_OpZero(v *Value, config *Config) bool {
if mem != v.Args[1] {
break
}
if !(mem.Op == OpStaticCall && isSameSym(mem.Aux, "runtime.newobject") && c == config.ctxt.FixedFrameSize()+config.PtrSize) {
if !(mem.Op == OpStaticCall && isSameSym(mem.Aux, "runtime.newobject") && c == config.ctxt.FixedFrameSize()+config.RegSize) {
break
}
v.reset(OpCopy)