From e932f0addc7d764a6bd534979b5cabaf0c1a6ad8 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Thu, 23 Jan 2020 21:45:11 -0800 Subject: [PATCH] cmd/compile: coalesce some 386 shift lowering rules MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit No changes to generated rule matching code. Change-Id: I0009146a6be30e151a403c4801c03abf0646703d Reviewed-on: https://go-review.googlesource.com/c/go/+/216999 Run-TryBot: Josh Bleecher Snyder Reviewed-by: Daniel Martí --- src/cmd/compile/internal/ssa/gen/386.rules | 42 +++++----------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/src/cmd/compile/internal/ssa/gen/386.rules b/src/cmd/compile/internal/ssa/gen/386.rules index 04caecd781..e1b15d3ad3 100644 --- a/src/cmd/compile/internal/ssa/gen/386.rules +++ b/src/cmd/compile/internal/ssa/gen/386.rules @@ -104,44 +104,20 @@ // Lowering shifts // Unsigned shifts need to return 0 if shift amount is >= width of shifted value. // result = (arg << shift) & (shift >= argbits ? 0 : 0xffffffffffffffff) -(Lsh32x32 x y) -> (ANDL (SHLL x y) (SBBLcarrymask (CMPLconst y [32]))) -(Lsh32x16 x y) -> (ANDL (SHLL x y) (SBBLcarrymask (CMPWconst y [32]))) -(Lsh32x8 x y) -> (ANDL (SHLL x y) (SBBLcarrymask (CMPBconst y [32]))) +(Lsh32x(32|16|8) x y) -> (ANDL (SHLL x y) (SBBLcarrymask (CMP(L|W|B)const y [32]))) +(Lsh16x(32|16|8) x y) -> (ANDL (SHLL x y) (SBBLcarrymask (CMP(L|W|B)const y [32]))) +(Lsh8x(32|16|8) x y) -> (ANDL (SHLL x y) (SBBLcarrymask (CMP(L|W|B)const y [32]))) -(Lsh16x32 x y) -> (ANDL (SHLL x y) (SBBLcarrymask (CMPLconst y [32]))) -(Lsh16x16 x y) -> (ANDL (SHLL x y) (SBBLcarrymask (CMPWconst y [32]))) -(Lsh16x8 x y) -> (ANDL (SHLL x y) (SBBLcarrymask (CMPBconst y [32]))) - -(Lsh8x32 x y) -> (ANDL (SHLL x y) (SBBLcarrymask (CMPLconst y [32]))) -(Lsh8x16 x y) -> (ANDL (SHLL x y) (SBBLcarrymask (CMPWconst y [32]))) -(Lsh8x8 x y) -> (ANDL (SHLL x y) (SBBLcarrymask (CMPBconst y [32]))) - -(Rsh32Ux32 x y) -> (ANDL (SHRL x y) (SBBLcarrymask (CMPLconst y [32]))) -(Rsh32Ux16 x y) -> (ANDL (SHRL x y) (SBBLcarrymask (CMPWconst y [32]))) -(Rsh32Ux8 x y) -> (ANDL (SHRL x y) (SBBLcarrymask (CMPBconst y [32]))) - -(Rsh16Ux32 x y) -> (ANDL (SHRW x y) (SBBLcarrymask (CMPLconst y [16]))) -(Rsh16Ux16 x y) -> (ANDL (SHRW x y) (SBBLcarrymask (CMPWconst y [16]))) -(Rsh16Ux8 x y) -> (ANDL (SHRW x y) (SBBLcarrymask (CMPBconst y [16]))) - -(Rsh8Ux32 x y) -> (ANDL (SHRB x y) (SBBLcarrymask (CMPLconst y [8]))) -(Rsh8Ux16 x y) -> (ANDL (SHRB x y) (SBBLcarrymask (CMPWconst y [8]))) -(Rsh8Ux8 x y) -> (ANDL (SHRB x y) (SBBLcarrymask (CMPBconst y [8]))) +(Rsh32Ux(32|16|8) x y) -> (ANDL (SHRL x y) (SBBLcarrymask (CMP(L|W|B)const y [32]))) +(Rsh16Ux(32|16|8) x y) -> (ANDL (SHRW x y) (SBBLcarrymask (CMP(L|W|B)const y [16]))) +(Rsh8Ux(32|16|8) x y) -> (ANDL (SHRB x y) (SBBLcarrymask (CMP(L|W|B)const y [8]))) // Signed right shift needs to return 0/-1 if shift amount is >= width of shifted value. // We implement this by setting the shift value to -1 (all ones) if the shift value is >= width. -(Rsh32x32 x y) -> (SARL x (ORL y (NOTL (SBBLcarrymask (CMPLconst y [32]))))) -(Rsh32x16 x y) -> (SARL x (ORL y (NOTL (SBBLcarrymask (CMPWconst y [32]))))) -(Rsh32x8 x y) -> (SARL x (ORL y (NOTL (SBBLcarrymask (CMPBconst y [32]))))) - -(Rsh16x32 x y) -> (SARW x (ORL y (NOTL (SBBLcarrymask (CMPLconst y [16]))))) -(Rsh16x16 x y) -> (SARW x (ORL y (NOTL (SBBLcarrymask (CMPWconst y [16]))))) -(Rsh16x8 x y) -> (SARW x (ORL y (NOTL (SBBLcarrymask (CMPBconst y [16]))))) - -(Rsh8x32 x y) -> (SARB x (ORL y (NOTL (SBBLcarrymask (CMPLconst y [8]))))) -(Rsh8x16 x y) -> (SARB x (ORL y (NOTL (SBBLcarrymask (CMPWconst y [8]))))) -(Rsh8x8 x y) -> (SARB x (ORL y (NOTL (SBBLcarrymask (CMPBconst y [8]))))) +(Rsh32x(32|16|8) x y) -> (SARL x (ORL y (NOTL (SBBLcarrymask (CMP(L|W|B)const y [32]))))) +(Rsh16x(32|16|8) x y) -> (SARW x (ORL y (NOTL (SBBLcarrymask (CMP(L|W|B)const y [16]))))) +(Rsh8x(32|16|8) x y) -> (SARB x (ORL y (NOTL (SBBLcarrymask (CMP(L|W|B)const y [8]))))) // constant shifts // generic opt rewrites all constant shifts to shift by Const64 -- 2.50.0