mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: add mul by ±2ⁿ code-generation tests for arm/arm64
This change adds code generation tests for multiplication by ±2ⁿ for arm and arm64, in preparation for a future CL which will remove the relevant architecture-specific SSA rules (the reduction is already performed by rules in generic.rules added in CL 36323). Change-Id: Iebdd5c3bb2fc632c85888569ff0c49f78569a862 Reviewed-on: https://go-review.googlesource.com/75752 Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
0966045039
commit
33a9f01729
1 changed files with 40 additions and 0 deletions
|
|
@ -1816,6 +1816,26 @@ var linuxS390XTests = []*asmTest{
|
||||||
}
|
}
|
||||||
|
|
||||||
var linuxARMTests = []*asmTest{
|
var linuxARMTests = []*asmTest{
|
||||||
|
// multiplication by powers of two
|
||||||
|
{
|
||||||
|
fn: `
|
||||||
|
func $(n int) int {
|
||||||
|
return 16*n
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
pos: []string{"\tSLL\t[$]4"},
|
||||||
|
neg: []string{"\tMUL\t"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fn: `
|
||||||
|
func $(n int) int {
|
||||||
|
return -32*n
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
pos: []string{"\tSLL\t[$]5"},
|
||||||
|
neg: []string{"\tMUL\t"},
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
fn: `
|
fn: `
|
||||||
func f0(x uint32) uint32 {
|
func f0(x uint32) uint32 {
|
||||||
|
|
@ -1943,6 +1963,26 @@ var linuxARMTests = []*asmTest{
|
||||||
}
|
}
|
||||||
|
|
||||||
var linuxARM64Tests = []*asmTest{
|
var linuxARM64Tests = []*asmTest{
|
||||||
|
// multiplication by powers of two
|
||||||
|
{
|
||||||
|
fn: `
|
||||||
|
func $(n int) int {
|
||||||
|
return 64*n
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
pos: []string{"\tLSL\t[$]6"},
|
||||||
|
neg: []string{"\tMUL\t"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fn: `
|
||||||
|
func $(n int) int {
|
||||||
|
return -128*n
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
pos: []string{"\tLSL\t[$]7"},
|
||||||
|
neg: []string{"\tMUL\t"},
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
fn: `
|
fn: `
|
||||||
func f0(x uint64) uint64 {
|
func f0(x uint64) uint64 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue