diff options
| author | Jayanth Krishnamurthy jayanth.krishnamurthy@ibm.com <jayanth.krishnamurthy@ibm.com> | 2025-10-15 04:18:52 -0500 |
|---|---|---|
| committer | Archana Ravindar <aravinda@redhat.com> | 2026-03-25 03:52:03 -0700 |
| commit | cbc2d06c9ba8285bb60f1055b44d4d1e742ca734 (patch) | |
| tree | 10c0fe04738b9da366a49f290a5173be1fd74f59 /test/codegen/shift.go | |
| parent | c52d784d0834d13b53e297dbcf7ebf057ba4eb8f (diff) | |
| download | go-cbc2d06c9ba8285bb60f1055b44d4d1e742ca734.tar.xz | |
cmd/compile: ppc64 fold (x+x)<<c into x<<(c+1)
On ppc64/ppc64le, rewrite (x + x) << c to x << (c+1) for constant shifts. This removes an ADD, shortens the dependency chain, and reduces code size.
Add rules for both 64-bit (SLDconst) and 32-bit (SLWconst), and extend
test/codegen/shift.go with ppc64x checks to assert a single SLD/SLW and
forbid ADD. Aligns ppc64 with other architectures that already assert
similar codegen in shift.go.
Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508
Cq-Include-Trybots: luci.golang.try:gotip-linux-ppc64_power10,gotip-linux-ppc64_power8,gotip-linux-ppc64le_power8,gotip-linux-ppc64le_power9,gotip-linux-ppc64le_power10
Reviewed-on: https://go-review.googlesource.com/c/go/+/712000
Reviewed-by: Archana Ravindar <aravinda@redhat.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Diffstat (limited to 'test/codegen/shift.go')
| -rw-r--r-- | test/codegen/shift.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/test/codegen/shift.go b/test/codegen/shift.go index 4222b0b845..9ae113d9d7 100644 --- a/test/codegen/shift.go +++ b/test/codegen/shift.go @@ -123,6 +123,7 @@ func lshConst32x1Add(x int32) int32 { // amd64:"SHLL [$]2" // loong64:"SLL [$]2" // riscv64:"SLLI [$]2" + // ppc64x:"SLW [$]2" -"ADD" return (x + x) << 1 } @@ -130,6 +131,7 @@ func lshConst64x1Add(x int64) int64 { // amd64:"SHLQ [$]2" // loong64:"SLLV [$]2" // riscv64:"SLLI [$]2" + // ppc64x:"SLD [$]2" -"ADD" return (x + x) << 1 } @@ -137,6 +139,7 @@ func lshConst32x2Add(x int32) int32 { // amd64:"SHLL [$]3" // loong64:"SLL [$]3" // riscv64:"SLLI [$]3" + // ppc64x:"SLW [$]3" -"ADD" return (x + x) << 2 } @@ -144,12 +147,14 @@ func lshConst64x2Add(x int64) int64 { // amd64:"SHLQ [$]3" // loong64:"SLLV [$]3" // riscv64:"SLLI [$]3" + // ppc64x:"SLD [$]3" -"ADD" return (x + x) << 2 } func lshConst32x31Add(x int32) int32 { // loong64:-"SLL " "MOVV R0" // riscv64:-"SLLI" "MOV [$]0" + // ppc64x:"ADD" "SLW [$]31" -"SLW [$]32" return (x + x) << 31 } |
