From b8990ec932c21e503f28e95e8323dbd9a090ac28 Mon Sep 17 00:00:00 2001 From: Lynn Boger Date: Wed, 29 Sep 2021 09:24:50 -0500 Subject: [PATCH] test: update test/codegen/noextend.go to work with either ABI on ppc64x This updates the codegen tests in noextend.go so they are not dependent on the ABI. Change-Id: I8433bea9dc78830c143290a7e0cf901b2397d38a Reviewed-on: https://go-review.googlesource.com/c/go/+/353070 Trust: Lynn Boger Run-TryBot: Lynn Boger TryBot-Result: Go Bot Reviewed-by: Cherry Mui --- test/codegen/noextend.go | 120 ++++++++++++++------------------------- 1 file changed, 44 insertions(+), 76 deletions(-) diff --git a/test/codegen/noextend.go b/test/codegen/noextend.go index 424fd2008d2..d8e2917bf27 100644 --- a/test/codegen/noextend.go +++ b/test/codegen/noextend.go @@ -15,19 +15,18 @@ var val32 [8]uint32 var val16 [8]uint16 var val8 [8]uint8 -// ----------------------------- // -// avoid zero/sign extensions // -// ----------------------------- // +// Avoid zero/sign extensions following a load +// which has extended the value correctly. +// Note: No tests are done for int8 since +// an extra extension is usually needed due to +// no signed byte load. -func set16(x8 int8, u8 uint8, y8 int8, z8 uint8) { +func set16(x8 int8, u8 *uint8, y8 int8, z8 uint8) { // Truncate not needed, load does sign/zero extend - // ppc64:-"MOVB\tR\\d+,\\sR\\d+" - // ppc64le:-"MOVB\tR\\d+,\\sR\\d+" - sval16[0] = int16(x8) // ppc64:-"MOVBZ\tR\\d+,\\sR\\d+" // ppc64le:-"MOVBZ\tR\\d+,\\sR\\d+" - val16[0] = uint16(u8) + val16[0] = uint16(*u8) // AND not needed due to size // ppc64:-"ANDCC" @@ -36,217 +35,186 @@ func set16(x8 int8, u8 uint8, y8 int8, z8 uint8) { // ppc64:-"ANDCC" // ppc64le:-"ANDCC" - val16[1] = 255 & uint16(u8+z8) + val16[1] = 255 & uint16(*u8+z8) } -func shiftidx(x8 int8, u8 uint8, x16 int16, u16 uint16, x32 int32, u32 uint32) { - // ppc64:-"MOVB\tR\\d+,\\sR\\d+" - // ppc64le:-"MOVB\tR\\d+,\\sR\\d+" - sval16[0] = int16(val16[x8>>1]) +func shiftidx(u8 *uint8, x16 *int16, u16 *uint16) { // ppc64:-"MOVBZ\tR\\d+,\\sR\\d+" // ppc64le:-"MOVBZ\tR\\d+,\\sR\\d+" - val16[0] = uint16(sval16[u8>>2]) + val16[0] = uint16(sval16[*u8>>2]) // ppc64:-"MOVH\tR\\d+,\\sR\\d+" // ppc64le:-"MOVH\tR\\d+,\\sR\\d+" - sval16[1] = int16(val16[x16>>1]) + sval16[1] = int16(val16[*x16>>1]) // ppc64:-"MOVHZ\tR\\d+,\\sR\\d+" // ppc64le:-"MOVHZ\tR\\d+,\\sR\\d+" - val16[1] = uint16(sval16[u16>>2]) + val16[1] = uint16(sval16[*u16>>2]) } -func setnox(x8 int8, u8 uint8, y8 int8, z8 uint8, x16 int16, u16 uint16, x32 int32, u32 uint32) { - // Truncate not needed due to sign/zero extension on load - - // ppc64:-"MOVB\tR\\d+,\\sR\\d+" - // ppc64le:-"MOVB\tR\\d+,\\sR\\d+" - sval16[0] = int16(x8) +func setnox(x8 int8, u8 *uint8, y8 *int8, z8 *uint8, x16 *int16, u16 *uint16, x32 *int32, u32 *uint32) { // ppc64:-"MOVBZ\tR\\d+,\\sR\\d+" // ppc64le:-"MOVBZ\tR\\d+,\\sR\\d+" - val16[0] = uint16(u8) + val16[0] = uint16(*u8) // AND not needed due to size // ppc64:-"ANDCC" // ppc64le:-"ANDCC" - sval16[1] = 255 & int16(x8+y8) + sval16[1] = 255 & int16(x8+*y8) // ppc64:-"ANDCC" // ppc64le:-"ANDCC" - val16[1] = 255 & uint16(u8+z8) - - // ppc64:-"MOVB\tR\\d+,\\sR\\d+" - // ppc64le:-"MOVB\tR\\d+,\\sR\\d+" - sval32[0] = int32(x8) + val16[1] = 255 & uint16(*u8+*z8) // ppc64:-"MOVH\tR\\d+,\\sR\\d+" // ppc64le:-"MOVH\tR\\d+,\\sR\\d+" - sval32[1] = int32(x16) + sval32[1] = int32(*x16) //ppc64:-"MOVBZ\tR\\d+,\\sR\\d+" //ppc64le:-"MOVBZ\tR\\d+,\\sR\\d+" - val32[0] = uint32(u8) + val32[0] = uint32(*u8) // ppc64:-"MOVHZ\tR\\d+,\\sR\\d+" // ppc64le:-"MOVHZ\tR\\d+,\\sR\\d+" - val32[1] = uint32(u16) - - // ppc64:-"MOVB\tR\\d+,\\sR\\d+" - // ppc64le:-"MOVB\tR\\d+,\\sR\\d+" - sval64[0] = int64(x8) + val32[1] = uint32(*u16) // ppc64:-"MOVH\tR\\d+,\\sR\\d+" // ppc64le:-"MOVH\tR\\d+,\\sR\\d+" - sval64[1] = int64(x16) + sval64[1] = int64(*x16) // ppc64:-"MOVW\tR\\d+,\\sR\\d+" // ppc64le:-"MOVW\tR\\d+,\\sR\\d+" - sval64[2] = int64(x32) + sval64[2] = int64(*x32) //ppc64:-"MOVBZ\tR\\d+,\\sR\\d+" //ppc64le:-"MOVBZ\tR\\d+,\\sR\\d+" - val64[0] = uint64(u8) + val64[0] = uint64(*u8) // ppc64:-"MOVHZ\tR\\d+,\\sR\\d+" // ppc64le:-"MOVHZ\tR\\d+,\\sR\\d+" - val64[1] = uint64(u16) + val64[1] = uint64(*u16) // ppc64:-"MOVWZ\tR\\d+,\\sR\\d+" // ppc64le:-"MOVWZ\tR\\d+,\\sR\\d+" - val64[2] = uint64(u32) + val64[2] = uint64(*u32) } -func cmp16(x8 int8, u8 uint8, x32 int32, u32 uint32, x64 int64, u64 uint64) bool { - // ppc64:-"MOVB\tR\\d+,\\sR\\d+" - // ppc64le:-"MOVB\tR\\d+,\\sR\\d+" - if int16(x8) == sval16[0] { - return true - } +func cmp16(u8 *uint8, x32 *int32, u32 *uint32, x64 *int64, u64 *uint64) bool { // ppc64:-"MOVBZ\tR\\d+,\\sR\\d+" // ppc64le:-"MOVBZ\tR\\d+,\\sR\\d+" - if uint16(u8) == val16[0] { + if uint16(*u8) == val16[0] { return true } // ppc64:-"MOVHZ\tR\\d+,\\sR\\d+" // ppc64le:-"MOVHZ\tR\\d+,\\sR\\d+" - if uint16(u32>>16) == val16[0] { + if uint16(*u32>>16) == val16[0] { return true } // ppc64:-"MOVHZ\tR\\d+,\\sR\\d+" // ppc64le:-"MOVHZ\tR\\d+,\\sR\\d+" - if uint16(u64>>48) == val16[0] { + if uint16(*u64>>48) == val16[0] { return true } // Verify the truncates are using the correct sign. // ppc64:-"MOVHZ\tR\\d+,\\sR\\d+" // ppc64le:-"MOVHZ\tR\\d+,\\sR\\d+" - if int16(x32) == sval16[0] { + if int16(*x32) == sval16[0] { return true } // ppc64:-"MOVH\tR\\d+,\\sR\\d+" // ppc64le:-"MOVH\tR\\d+,\\sR\\d+" - if uint16(u32) == val16[0] { + if uint16(*u32) == val16[0] { return true } // ppc64:-"MOVHZ\tR\\d+,\\sR\\d+" // ppc64le:-"MOVHZ\tR\\d+,\\sR\\d+" - if int16(x64) == sval16[0] { + if int16(*x64) == sval16[0] { return true } // ppc64:-"MOVH\tR\\d+,\\sR\\d+" // ppc64le:-"MOVH\tR\\d+,\\sR\\d+" - if uint16(u64) == val16[0] { + if uint16(*u64) == val16[0] { return true } return false } -func cmp32(x8 int8, u8 uint8, x16 int16, u16 uint16, x64 int64, u64 uint64) bool { - // ppc64:-"MOVB\tR\\d+,\\sR\\d+" - // ppc64le:-"MOVB\tR\\d+,\\sR\\d+" - if int32(x8) == sval32[0] { - return true - } +func cmp32(u8 *uint8, x16 *int16, u16 *uint16, x64 *int64, u64 *uint64) bool { // ppc64:-"MOVBZ\tR\\d+,\\sR\\d+" // ppc64le:-"MOVBZ\tR\\d+,\\sR\\d+" - if uint32(u8) == val32[0] { + if uint32(*u8) == val32[0] { return true } // ppc64:-"MOVH\tR\\d+,\\sR\\d+" // ppc64le:-"MOVH\tR\\d+,\\sR\\d+" - if int32(x16) == sval32[0] { + if int32(*x16) == sval32[0] { return true } // ppc64:-"MOVHZ\tR\\d+,\\sR\\d+" // ppc64le:-"MOVHZ\tR\\d+,\\sR\\d+" - if uint32(u16) == val32[0] { + if uint32(*u16) == val32[0] { return true } // Verify the truncates are using the correct sign. // ppc64:-"MOVWZ\tR\\d+,\\sR\\d+" // ppc64le:-"MOVWZ\tR\\d+,\\sR\\d+" - if int32(x64) == sval32[0] { + if int32(*x64) == sval32[0] { return true } // ppc64:-"MOVW\tR\\d+,\\sR\\d+" // ppc64le:-"MOVW\tR\\d+,\\sR\\d+" - if uint32(u64) == val32[0] { + if uint32(*u64) == val32[0] { return true } return false } -func cmp64(x8 int8, u8 uint8, x16 int16, u16 uint16, x32 int32, u32 uint32) bool { - // ppc64:-"MOVB\tR\\d+,\\sR\\d+" - // ppc64le:-"MOVB\tR\\d+,\\sR\\d+" - if int64(x8) == sval64[0] { - return true - } +func cmp64(u8 *uint8, x16 *int16, u16 *uint16, x32 *int32, u32 *uint32) bool { // ppc64:-"MOVBZ\tR\\d+,\\sR\\d+" // ppc64le:-"MOVBZ\tR\\d+,\\sR\\d+" - if uint64(u8) == val64[0] { + if uint64(*u8) == val64[0] { return true } // ppc64:-"MOVH\tR\\d+,\\sR\\d+" // ppc64le:-"MOVH\tR\\d+,\\sR\\d+" - if int64(x16) == sval64[0] { + if int64(*x16) == sval64[0] { return true } // ppc64:-"MOVHZ\tR\\d+,\\sR\\d+" // ppc64le:-"MOVHZ\tR\\d+,\\sR\\d+" - if uint64(u16) == val64[0] { + if uint64(*u16) == val64[0] { return true } // ppc64:-"MOVW\tR\\d+,\\sR\\d+" // ppc64le:-"MOVW\tR\\d+,\\sR\\d+" - if int64(x32) == sval64[0] { + if int64(*x32) == sval64[0] { return true } // ppc64:-"MOVWZ\tR\\d+,\\sR\\d+" // ppc64le:-"MOVWZ\tR\\d+,\\sR\\d+" - if uint64(u32) == val64[0] { + if uint64(*u32) == val64[0] { return true } return false