From 85dcc709a8523877063b05c6806631c7f47e99ab Mon Sep 17 00:00:00 2001 From: Alberto Donizetti Date: Tue, 6 Mar 2018 09:39:14 +0100 Subject: [PATCH] test/codegen: port math/bits.TrailingZeros tests to codegen And remove them from ssa_test. Change-Id: Ib5de5c0d908f23915e0847eca338cacf2fa5325b Reviewed-on: https://go-review.googlesource.com/98795 Reviewed-by: Giovanni Bajo --- src/cmd/compile/internal/gc/asm_test.go | 65 ------------------------- test/codegen/mathbits.go | 34 +++++++++++++ 2 files changed, 34 insertions(+), 65 deletions(-) diff --git a/src/cmd/compile/internal/gc/asm_test.go b/src/cmd/compile/internal/gc/asm_test.go index 1e9bd20548..deafdf5894 100644 --- a/src/cmd/compile/internal/gc/asm_test.go +++ b/src/cmd/compile/internal/gc/asm_test.go @@ -523,38 +523,6 @@ var linuxAMD64Tests = []*asmTest{ pos: []string{"\tBTQ\t\\$60"}, }, // Intrinsic tests for math/bits - { - fn: ` - func f41(a uint64) int { - return bits.TrailingZeros64(a) - } - `, - pos: []string{"\tBSFQ\t", "\tMOVL\t\\$64,", "\tCMOVQEQ\t"}, - }, - { - fn: ` - func f42(a uint32) int { - return bits.TrailingZeros32(a) - } - `, - pos: []string{"\tBSFQ\t", "\tORQ\t[^$]", "\tMOVQ\t\\$4294967296,"}, - }, - { - fn: ` - func f43(a uint16) int { - return bits.TrailingZeros16(a) - } - `, - pos: []string{"\tBSFQ\t", "\tORQ\t\\$65536,"}, - }, - { - fn: ` - func f44(a uint8) int { - return bits.TrailingZeros8(a) - } - `, - pos: []string{"\tBSFQ\t", "\tORQ\t\\$256,"}, - }, { fn: ` func f45(a uint64) uint64 { @@ -1230,39 +1198,6 @@ var linuxS390XTests = []*asmTest{ pos: []string{"\tFMSUBS\t"}, }, // Intrinsic tests for math/bits - { - fn: ` - func f18(a uint64) int { - return bits.TrailingZeros64(a) - } - `, - pos: []string{"\tFLOGR\t"}, - }, - { - fn: ` - func f19(a uint32) int { - return bits.TrailingZeros32(a) - } - `, - pos: []string{"\tFLOGR\t", "\tMOVWZ\t"}, - }, - { - fn: ` - func f20(a uint16) int { - return bits.TrailingZeros16(a) - } - `, - pos: []string{"\tFLOGR\t", "\tOR\t\\$65536,"}, - }, - { - fn: ` - func f21(a uint8) int { - return bits.TrailingZeros8(a) - } - `, - pos: []string{"\tFLOGR\t", "\tOR\t\\$256,"}, - }, - // Intrinsic tests for math/bits { fn: ` func f22(a uint64) uint64 { diff --git a/test/codegen/mathbits.go b/test/codegen/mathbits.go index 98ee8f2a0b..f930046a3b 100644 --- a/test/codegen/mathbits.go +++ b/test/codegen/mathbits.go @@ -95,3 +95,37 @@ func Len8(n uint8) int { //mips:"CLZ" return bits.Len8(n) } + +// ------------------------ // +// bits.TrailingZeros // +// ------------------------ // + +func TrailingZeros(n uint) int { + //amd64:"BSFQ","MOVL\t\\$64","CMOVQEQ" + //s390x:"FLOGR" + return bits.TrailingZeros(n) +} + +func TrailingZeros64(n uint64) int { + //amd64:"BSFQ","MOVL\t\\$64","CMOVQEQ" + //s390x:"FLOGR" + return bits.TrailingZeros64(n) +} + +func TrailingZeros32(n uint32) int { + //amd64:"MOVQ\t\\$4294967296","ORQ\t[^$]","BSFQ" + //s390x:"FLOGR","MOVWZ" + return bits.TrailingZeros32(n) +} + +func TrailingZeros16(n uint16) int { + //amd64:"BSFQ","ORQ\t\\$65536" + //s390x:"FLOGR","OR\t\\$65536" + return bits.TrailingZeros16(n) +} + +func TrailingZeros8(n uint8) int { + //amd64:"BSFQ","ORQ\t\\$256" + //s390x:"FLOGR","OR\t\\$256" + return bits.TrailingZeros8(n) +} -- 2.48.1