diff options
author | Brian Kessler <brian.m.kessler@gmail.com> | 2019-09-08 21:50:07 -0600 |
---|---|---|
committer | Martin Möhrmann <moehrmann@google.com> | 2019-11-07 16:30:46 +0000 |
commit | 6b1d5471b9ab649322def7075d488c65d5f78cbf (patch) | |
tree | fe326c2e33cd1e5b61562ff75fe81c278339e8f8 /test/codegen/arithmetic.go | |
parent | 14849f0fa57c67996bb00bd42bb14cef9f4e9a1e (diff) | |
download | go-git-6b1d5471b9ab649322def7075d488c65d5f78cbf.tar.gz |
cmd/compile: add signed indivisibility by power of 2 rules
Commit 44343c777c (CL 173557) added rules for handling
divisibility checks for powers of 2 for signed integers, x%c ==0.
This change adds the complementary indivisibility rules, x%c != 0.
Fixes #34166
Change-Id: I87379e30af7aff633371acca82db2397da9b2c07
Reviewed-on: https://go-review.googlesource.com/c/go/+/194219
Run-TryBot: Brian Kessler <brian.m.kessler@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/codegen/arithmetic.go')
-rw-r--r-- | test/codegen/arithmetic.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/test/codegen/arithmetic.go b/test/codegen/arithmetic.go index dcbc6d3f97..a076664e8e 100644 --- a/test/codegen/arithmetic.go +++ b/test/codegen/arithmetic.go @@ -188,14 +188,24 @@ func Pow2Mods(n1 uint, n2 int) (uint, int) { } // Check that signed divisibility checks get converted to AND on low bits -func Pow2DivisibleSigned(n int) bool { +func Pow2DivisibleSigned(n1, n2 int) (bool, bool) { // 386:"TESTL\t[$]63",-"DIVL",-"SHRL" // amd64:"TESTQ\t[$]63",-"DIVQ",-"SHRQ" // arm:"AND\t[$]63",-".*udiv",-"SRA" // arm64:"AND\t[$]63",-"UDIV",-"ASR" // ppc64:"ANDCC\t[$]63",-"SRAD" // ppc64le:"ANDCC\t[$]63",-"SRAD" - return n%64 == 0 // signed + a := n1%64 == 0 // signed divisible + + // 386:"TESTL\t[$]63",-"DIVL",-"SHRL" + // amd64:"TESTQ\t[$]63",-"DIVQ",-"SHRQ" + // arm:"AND\t[$]63",-".*udiv",-"SRA" + // arm64:"AND\t[$]63",-"UDIV",-"ASR" + // ppc64:"ANDCC\t[$]63",-"SRAD" + // ppc64le:"ANDCC\t[$]63",-"SRAD" + b := n2%64 != 0 // signed indivisible + + return a, b } // Check that constant modulo divs get turned into MULs |