aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/rewrite.go
diff options
context:
space:
mode:
authorLynn Boger <laboger@linux.vnet.ibm.com>2020-11-16 09:40:45 -0500
committerLynn Boger <laboger@linux.vnet.ibm.com>2020-11-17 13:20:20 +0000
commit0ae3b7cb742c586df9b68d9eac042b32148abf9c (patch)
treed3a7aacdea350bff1e538f8741dfec094081dc5f /src/cmd/compile/internal/ssa/rewrite.go
parent869e2957b9f66021581b839cadce6cb48ad46114 (diff)
downloadgo-0ae3b7cb742c586df9b68d9eac042b32148abf9c.tar.gz
go-0ae3b7cb742c586df9b68d9eac042b32148abf9c.zip
cmd/compile: fix rules regression with shifts on PPC64
Some rules for PPC64 were checking for a case where a shift followed by an 'and' of a mask could be lowered, depending on the format of the mask. The function to verify if the mask was valid for this purpose was not checking if the mask was 0 which we don't want to allow. This case can happen if previous optimizations resulted in that mask value. This fixes isPPC64ValidShiftMask to check for a mask of 0 and return false. This also adds a codegen testcase to verify it doesn't try to match the rules in the future. Fixes #42610 Change-Id: I565d94e88495f51321ab365d6388c01e791b4dbb Reviewed-on: https://go-review.googlesource.com/c/go/+/270358 Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Paul Murphy <murp@ibm.com> Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org> Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/rewrite.go')
-rw-r--r--src/cmd/compile/internal/ssa/rewrite.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/ssa/rewrite.go b/src/cmd/compile/internal/ssa/rewrite.go
index 39aa63d947..24efd38fb7 100644
--- a/src/cmd/compile/internal/ssa/rewrite.go
+++ b/src/cmd/compile/internal/ssa/rewrite.go
@@ -1427,10 +1427,11 @@ func DecodePPC64RotateMask(sauxint int64) (rotate, mb, me int64, mask uint64) {
return
}
-// This verifies that the mask occupies the
-// rightmost bits.
+// This verifies that the mask is a set of
+// consecutive bits including the least
+// significant bit.
func isPPC64ValidShiftMask(v int64) bool {
- if ((v + 1) & v) == 0 {
+ if (v != 0) && ((v+1)&v) == 0 {
return true
}
return false