From 68819fb6d2bab59e4eadcdf62aa4a2a54417d640 Mon Sep 17 00:00:00 2001 From: Brian Kessler Date: Sun, 17 Mar 2019 23:11:00 -0600 Subject: cmd/compile: add signed divisibility by power of 2 rules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For powers of two (c=1< --- test/codegen/arithmetic.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/codegen') diff --git a/test/codegen/arithmetic.go b/test/codegen/arithmetic.go index b5976be9d2..535e3349fc 100644 --- a/test/codegen/arithmetic.go +++ b/test/codegen/arithmetic.go @@ -185,6 +185,17 @@ func Pow2Mods(n1 uint, n2 int) (uint, int) { return a, b } +// Check that signed divisibility checks get converted to AND on low bits +func Pow2DivisibleSigned(n int) bool { + // 386:"TESTL\t[$]63",-"DIVL" + // amd64:"TESTQ\t[$]63",-"DIVQ" + // arm:"AND\t[$]63",-".*udiv" + // arm64:"AND\t[$]63",-"UDIV" + // ppc64:"ANDCC\t[$]63" + // ppc64le:"ANDCC\t[$]63" + return n%64 == 0 // signed +} + // Check that constant modulo divs get turned into MULs func ConstMods(n1 uint, n2 int) (uint, int) { // amd64:"MOVQ\t[$]-1085102592571150095","MULQ",-"DIVQ" -- cgit v1.3-5-g9baa