mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: fix ANDI/SRWI merge on ppc64
The shift amount should be masked to avoid rotation values beyond the numer of bits. In this case, if the shift amount is 0, it should rotate 0, not 32. Fixes #45589 Change-Id: I1e764497a39d0ec128e29af42352b70c70b2ecc5 Reviewed-on: https://go-review.googlesource.com/c/go/+/310569 Run-TryBot: Paul Murphy <murp@ibm.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org> Trust: Carlos Eduardo Seo <carlos.seo@linaro.org>
This commit is contained in:
parent
699a7c0fe9
commit
c8fb0ec5a0
2 changed files with 2 additions and 1 deletions
|
|
@ -1492,7 +1492,7 @@ func mergePPC64AndSrwi(m, s int64) int64 {
|
|||
if !isPPC64WordRotateMask(mask) {
|
||||
return 0
|
||||
}
|
||||
return encodePPC64RotateMask(32-s, mask, 32)
|
||||
return encodePPC64RotateMask((32-s)&31, mask, 32)
|
||||
}
|
||||
|
||||
// Test if a shift right feeding into a CLRLSLDI can be merged into RLWINM.
|
||||
|
|
|
|||
|
|
@ -205,6 +205,7 @@ func TestMergePPC64AndSrwi(t *testing.T) {
|
|||
{0x00000000, 4, false, 0, 0},
|
||||
{0xF0000000, 4, false, 0, 0},
|
||||
{0xF0000000, 32, false, 0, 0},
|
||||
{0xFFFFFFFF, 0, true, 0, 0xFFFFFFFF},
|
||||
}
|
||||
for i, v := range tests {
|
||||
result := mergePPC64AndSrwi(v.and, v.srw)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue