diff --git a/src/cmd/compile/internal/ssa/gen/generic.rules b/src/cmd/compile/internal/ssa/gen/generic.rules index 740ba8606a..4adbc9e45f 100644 --- a/src/cmd/compile/internal/ssa/gen/generic.rules +++ b/src/cmd/compile/internal/ssa/gen/generic.rules @@ -1386,9 +1386,9 @@ // recognize runtime.newobject and don't Zero/Nilcheck it (Zero (Load (OffPtr [c] (SP)) mem) mem) - && mem.Op == OpStaticCall + && 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. diff --git a/src/cmd/compile/internal/ssa/rewritegeneric.go b/src/cmd/compile/internal/ssa/rewritegeneric.go index f17bf3343c..0709eb89bb 100644 --- a/src/cmd/compile/internal/ssa/rewritegeneric.go +++ b/src/cmd/compile/internal/ssa/rewritegeneric.go @@ -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)