diff options
author | Paul E. Murphy <murp@ibm.com> | 2023-06-27 17:17:33 -0500 |
---|---|---|
committer | Paul Murphy <murp@ibm.com> | 2023-09-06 16:34:20 +0000 |
commit | 5cdb132228b90732d57215893a9910ded694c585 (patch) | |
tree | e04030ad47b1d7654bd2ad4285a4185ec732836e /test/codegen | |
parent | 2186909d8651728cb71a4e02e0fe7b2c3d55e9b4 (diff) | |
download | go-5cdb132228b90732d57215893a9910ded694c585.tar.gz go-5cdb132228b90732d57215893a9910ded694c585.zip |
cmd/compile/internal/ssa: improve masking codegen on PPC64
Generate RLDIC[LR] instead of MOVD mask, Rx; AND Rx, Ry, Rz.
This helps reduce code size, and reduces the latency caused
by the constant load.
Similarly, for smaller-than-register values, truncate constants
which exceed the range of the value's type to avoid needing to
load a constant.
Change-Id: I6019684795eb8962d4fd6d9585d08b17c15e7d64
Reviewed-on: https://go-review.googlesource.com/c/go/+/515576
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'test/codegen')
-rw-r--r-- | test/codegen/bits.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/codegen/bits.go b/test/codegen/bits.go index 88d5ebe9cf..67daf12d62 100644 --- a/test/codegen/bits.go +++ b/test/codegen/bits.go @@ -394,3 +394,29 @@ func zeroextendAndMask8to64(a int8, b int16) (x, y uint64) { return } + +// Verify rotate and mask instructions, and further simplified instructions for small types +func bitRotateAndMask(io64 [4]uint64, io32 [4]uint32, io16 [4]uint16, io8 [4]uint8) { + // ppc64x: "RLDICR\t[$]0, R[0-9]*, [$]47, R" + io64[0] = io64[0] & 0xFFFFFFFFFFFF0000 + // ppc64x: "RLDICL\t[$]0, R[0-9]*, [$]16, R" + io64[1] = io64[1] & 0x0000FFFFFFFFFFFF + // ppc64x: -"SRD", -"AND", "RLDICL\t[$]60, R[0-9]*, [$]16, R" + io64[2] = (io64[2] >> 4) & 0x0000FFFFFFFFFFFF + // ppc64x: -"SRD", -"AND", "RLDICL\t[$]36, R[0-9]*, [$]28, R" + io64[3] = (io64[3] >> 28) & 0x0000FFFFFFFFFFFF + + // ppc64x: "RLWNM\t[$]0, R[0-9]*, [$]4, [$]19, R" + io32[0] = io32[0] & 0x0FFFF000 + // ppc64x: "RLWNM\t[$]0, R[0-9]*, [$]20, [$]3, R" + io32[1] = io32[1] & 0xF0000FFF + // ppc64x: -"RLWNM", MOVD, AND + io32[2] = io32[2] & 0xFFFF0002 + + var bigc uint32 = 0x12345678 + // ppc64x: "ANDCC\t[$]22136" + io16[0] = io16[0] & uint16(bigc) + + // ppc64x: "ANDCC\t[$]120" + io8[0] = io8[0] & uint8(bigc) +} |