]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.19] cmd/compile: on PPC64, fix sign/zero extension when masking
authorPaul E. Murphy <murp@ibm.com>
Tue, 11 Jul 2023 14:07:43 +0000 (09:07 -0500)
committerGopher Robot <gobot@golang.org>
Wed, 19 Jul 2023 19:11:01 +0000 (19:11 +0000)
commit6ce543d137fbb72e036d2d0b4d892d194b9bef40
tree0ca1cad6f582443f6bb5db0119f9d20919a17a3a
parente58941fc25771784319ebd0178e566ecf7d3d8c1
[release-branch.go1.19] cmd/compile: on PPC64, fix sign/zero extension when masking

This backport required manual cleanup as go1.20 combined the
ANDCCconst and ANDconst opcodes into one. Similarly, CL 456736
introduced a suble bug by using (Select1 (ANDCCconst ...)). This
usually worked because the same rule quietly changes the type
of the newly created ANDCCconst to a tuple. This change exposed
the bug, so fix it too.

(ANDconst [y] (MOV.*reg x)) should only be merged when zero
extending. Otherwise, sign bits are lost on negative values.

(ANDconst [0xFF] (MOVBreg x)) should be simplified to a zero
extension of x. Likewise for the MOVHreg variant.

Fixes #61319

Change-Id: I04e4fd7dc6a826e870681f37506620d48393698b
Reviewed-on: https://go-review.googlesource.com/c/go/+/508775
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/509018
Auto-Submit: Heschi Kreinick <heschi@google.com>
TryBot-Bypass: Heschi Kreinick <heschi@google.com>
src/cmd/compile/internal/ssa/gen/PPC64.rules
src/cmd/compile/internal/ssa/rewritePPC64.go
test/codegen/bits.go