mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile/internal/ssa: inline memmove with known size
Replace calls to memmove with known (constant) size, with OpMove. Do it only if it is safe from aliasing point of view. Helps with code like this: append(buf,"const str"...) In strconv this provides nice benefit: Quote-6 731ns ± 2% 647ns ± 3% -11.41% (p=0.000 n=10+10) QuoteRune-6 117ns ± 5% 111ns ± 1% -4.54% (p=0.000 n=10+10) AppendQuote-6 475ns ± 0% 396ns ± 0% -16.59% (p=0.000 n=9+10) AppendQuoteRune-6 32.0ns ± 0% 27.4ns ± 0% -14.41% (p=0.000 n=8+9) Change-Id: I7704f5c51b46aed2d8f033de74c75140fc35036c Reviewed-on: https://go-review.googlesource.com/54394 Run-TryBot: Ilya Tocar <ilya.tocar@intel.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
ad3742f4ac
commit
f3884680fc
6 changed files with 189 additions and 2 deletions
|
|
@ -1191,6 +1191,36 @@ var linuxAMD64Tests = []*asmTest{
|
|||
`,
|
||||
pos: []string{"\tANDQ\t\\$4095,"},
|
||||
},
|
||||
{
|
||||
// Test that small memmove was replaced with direct movs
|
||||
fn: `
|
||||
func $() {
|
||||
x := [...]byte{1, 2, 3, 4, 5, 6, 7}
|
||||
copy(x[1:], x[:])
|
||||
}
|
||||
`,
|
||||
neg: []string{"memmove"},
|
||||
},
|
||||
{
|
||||
// Same as above but with different size
|
||||
fn: `
|
||||
func $() {
|
||||
x := [...]byte{1, 2, 3, 4}
|
||||
copy(x[1:], x[:])
|
||||
}
|
||||
`,
|
||||
neg: []string{"memmove"},
|
||||
},
|
||||
{
|
||||
// Same as above but with different size
|
||||
fn: `
|
||||
func $() {
|
||||
x := [...]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
|
||||
copy(x[1:], x[:])
|
||||
}
|
||||
`,
|
||||
neg: []string{"memmove"},
|
||||
},
|
||||
}
|
||||
|
||||
var linux386Tests = []*asmTest{
|
||||
|
|
@ -1322,6 +1352,26 @@ var linux386Tests = []*asmTest{
|
|||
`,
|
||||
pos: []string{"\tANDL\t\\$4095,"},
|
||||
},
|
||||
{
|
||||
// Test that small memmove was replaced with direct movs
|
||||
fn: `
|
||||
func $() {
|
||||
x := [...]byte{1, 2, 3, 4, 5, 6, 7}
|
||||
copy(x[1:], x[:])
|
||||
}
|
||||
`,
|
||||
neg: []string{"memmove"},
|
||||
},
|
||||
{
|
||||
// Same as above but with different size
|
||||
fn: `
|
||||
func $() {
|
||||
x := [...]byte{1, 2, 3, 4}
|
||||
copy(x[1:], x[:])
|
||||
}
|
||||
`,
|
||||
neg: []string{"memmove"},
|
||||
},
|
||||
}
|
||||
|
||||
var linuxS390XTests = []*asmTest{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue