From 6e5398bad16aba15db365b72cb70d1177330b603 Mon Sep 17 00:00:00 2001 From: "Paul E. Murphy" Date: Fri, 16 Feb 2024 13:29:16 -0600 Subject: cmd/asm,cmd/compile: generate less instructions for most 32 bit constant adds on ppc64x For GOPPC64 < 10 targets, most large 32 bit constants (those exceeding int16 capacity) can be added using two instructions instead of 3. This cannot be done for values greater than 0x7FFF7FFF, so this must be done during asm preprocessing as the optab matching rules cannot differentiate this special case. Likewise, constants 0x8000 <= x < 0x10000 are not converted. The assembler currently generates 2 instructions sequences for these constants. Change-Id: I1ccc839c6c28fc32f15d286b2e52e2d22a2a06d4 Reviewed-on: https://go-review.googlesource.com/c/go/+/568116 Reviewed-by: Cherry Mui Reviewed-by: Michael Knyszek LUCI-TryBot-Result: Go LUCI Run-TryBot: Paul Murphy Reviewed-by: Lynn Boger TryBot-Result: Gopher Robot --- test/codegen/arithmetic.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test') diff --git a/test/codegen/arithmetic.go b/test/codegen/arithmetic.go index 174c2dbcc9..dc3bab7be9 100644 --- a/test/codegen/arithmetic.go +++ b/test/codegen/arithmetic.go @@ -23,6 +23,32 @@ func AddLargeConst(a uint64, out []uint64) { // ppc64x/power9:"MOVD\t[$]-1", "SLD\t[$]33" "ADD\tR[0-9]*" // ppc64x/power8:"MOVD\t[$]-1", "SLD\t[$]33" "ADD\tR[0-9]*" out[1] = a + 0xFFFFFFFE00000000 + // ppc64x/power10:"ADD\t[$]1234567," + // ppc64x/power9:"ADDIS\t[$]19,", "ADD\t[$]-10617," + // ppc64x/power8:"ADDIS\t[$]19,", "ADD\t[$]-10617," + out[2] = a + 1234567 + // ppc64x/power10:"ADD\t[$]-1234567," + // ppc64x/power9:"ADDIS\t[$]-19,", "ADD\t[$]10617," + // ppc64x/power8:"ADDIS\t[$]-19,", "ADD\t[$]10617," + out[3] = a - 1234567 + // ppc64x/power10:"ADD\t[$]2147450879," + // ppc64x/power9:"ADDIS\t[$]32767,", "ADD\t[$]32767," + // ppc64x/power8:"ADDIS\t[$]32767,", "ADD\t[$]32767," + out[4] = a + 0x7FFF7FFF + // ppc64x/power10:"ADD\t[$]-2147483647," + // ppc64x/power9:"ADDIS\t[$]-32768,", "ADD\t[$]1," + // ppc64x/power8:"ADDIS\t[$]-32768,", "ADD\t[$]1," + out[5] = a - 2147483647 + // ppc64x:"ADDIS\t[$]-32768,", ^"ADD\t" + out[6] = a - 2147483648 + // ppc64x:"ADD\t[$]2147450880,", ^"ADDIS\t" + out[7] = a + 0x7FFF8000 + // ppc64x:"ADD\t[$]-32768,", ^"ADDIS\t" + out[8] = a - 32768 + // ppc64x/power10:"ADD\t[$]-32769," + // ppc64x/power9:"ADDIS\t[$]-1,", "ADD\t[$]32767," + // ppc64x/power8:"ADDIS\t[$]-1,", "ADD\t[$]32767," + out[9] = a - 32769 } // ----------------- // -- cgit v1.2.3-54-g00ecf