aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPaul E. Murphy <murp@ibm.com>2024-02-16 13:29:16 -0600
committerPaul Murphy <murp@ibm.com>2024-03-13 13:58:44 +0000
commit6e5398bad16aba15db365b72cb70d1177330b603 (patch)
treeea00cfdf9c6f9d96be1065237d4b25c8d01a2823 /test
parenta46ecdca36b2359e7496c6d694703a9a9706d760 (diff)
downloadgo-6e5398bad16aba15db365b72cb70d1177330b603.tar.gz
go-6e5398bad16aba15db365b72cb70d1177330b603.zip
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 <cherryyz@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Paul Murphy <murp@ibm.com> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'test')
-rw-r--r--test/codegen/arithmetic.go26
1 files changed, 26 insertions, 0 deletions
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
}
// ----------------- //