]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: use more ORs in generic.rules
authorAlberto Donizetti <alb.donizetti@gmail.com>
Sat, 24 Mar 2018 11:08:00 +0000 (12:08 +0100)
committerAlberto Donizetti <alb.donizetti@gmail.com>
Tue, 27 Mar 2018 07:49:49 +0000 (07:49 +0000)
No changes in the actual generated compiler code.

Change-Id: I206a7bf7b60f70a73640119fc92974f79ed95a6b
Reviewed-on: https://go-review.googlesource.com/102416
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
src/cmd/compile/internal/ssa/gen/generic.rules

index 8d394438816c6b08f6aac675c2d660552f5b85b3..e6797103d517f056f3bc728f249c54b45dfda07a 100644 (file)
 (Mul32 (Const32 <t> [c]) (Add32 <t> (Const32 <t> [d]) x)) ->
   (Add32 (Const32 <t> [int64(int32(c*d))]) (Mul32 <t> (Const32 <t> [c]) x))
 
-// Rewrite x*y + x*z  to  x*(y+z)
-(Add64 <t> (Mul64 x y) (Mul64 x z)) -> (Mul64 x (Add64 <t> y z))
-(Add32 <t> (Mul32 x y) (Mul32 x z)) -> (Mul32 x (Add32 <t> y z))
-(Add16 <t> (Mul16 x y) (Mul16 x z)) -> (Mul16 x (Add16 <t> y z))
-(Add8  <t> (Mul8  x y) (Mul8  x z)) -> (Mul8  x (Add8  <t> y z))
-
-// Rewrite x*y - x*z  to  x*(y-z)
-(Sub64 <t> (Mul64 x y) (Mul64 x z)) -> (Mul64 x (Sub64 <t> y z))
-(Sub32 <t> (Mul32 x y) (Mul32 x z)) -> (Mul32 x (Sub32 <t> y z))
-(Sub16 <t> (Mul16 x y) (Mul16 x z)) -> (Mul16 x (Sub16 <t> y z))
-(Sub8  <t> (Mul8  x y) (Mul8  x z)) -> (Mul8  x (Sub8  <t> y z))
+// Rewrite x*y ± x*z  to  x*(y±z)
+(Add(64|32|16|8) <t> (Mul(64|32|16|8) x y) (Mul(64|32|16|8) x z))
+       -> (Mul(64|32|16|8) x (Add(64|32|16|8) <t> y z))
+(Sub(64|32|16|8) <t> (Mul(64|32|16|8) x y) (Mul(64|32|16|8) x z))
+       -> (Mul(64|32|16|8) x (Sub(64|32|16|8) <t> y z))
 
 // rewrite shifts of 8/16/32 bit consts into 64 bit consts to reduce
 // the number of the other rewrite rules for const shifts
 (Rsh8Ux8  <t> x (Const8  [c])) -> (Rsh8Ux64 x (Const64 <t> [int64(uint8(c))]))
 
 // shifts by zero
-(Lsh64x64  x (Const64 [0])) -> x
-(Rsh64x64  x (Const64 [0])) -> x
-(Rsh64Ux64 x (Const64 [0])) -> x
-(Lsh32x64  x (Const64 [0])) -> x
-(Rsh32x64  x (Const64 [0])) -> x
-(Rsh32Ux64 x (Const64 [0])) -> x
-(Lsh16x64  x (Const64 [0])) -> x
-(Rsh16x64  x (Const64 [0])) -> x
-(Rsh16Ux64 x (Const64 [0])) -> x
-(Lsh8x64   x (Const64 [0])) -> x
-(Rsh8x64   x (Const64 [0])) -> x
-(Rsh8Ux64  x (Const64 [0])) -> x
-
-// zero shifted.
+(Lsh(64|32|16|8)x64  x (Const64 [0])) -> x
+(Rsh(64|32|16|8)x64  x (Const64 [0])) -> x
+(Rsh(64|32|16|8)Ux64 x (Const64 [0])) -> x
+
+// zero shifted
 (Lsh64x(64|32|16|8)  (Const64 [0]) _) -> (Const64 [0])
 (Rsh64x(64|32|16|8)  (Const64 [0]) _) -> (Const64 [0])
 (Rsh64Ux(64|32|16|8) (Const64 [0]) _) -> (Const64 [0])
 
 (Neg(64|32|16|8) (Sub(64|32|16|8) x y)) -> (Sub(64|32|16|8) y x)
 
-(Add8  (Const8  [1]) (Com8  x)) -> (Neg8  x)
-(Add16 (Const16 [1]) (Com16 x)) -> (Neg16 x)
-(Add32 (Const32 [1]) (Com32 x)) -> (Neg32 x)
-(Add64 (Const64 [1]) (Com64 x)) -> (Neg64 x)
-
-(And64 x (And64 x y)) -> (And64 x y)
-(And32 x (And32 x y)) -> (And32 x y)
-(And16 x (And16 x y)) -> (And16 x y)
-(And8  x (And8  x y)) -> (And8  x y)
-(Or64 x (Or64 x y)) -> (Or64 x y)
-(Or32 x (Or32 x y)) -> (Or32 x y)
-(Or16 x (Or16 x y)) -> (Or16 x y)
-(Or8  x (Or8  x y)) -> (Or8  x y)
+(Add(64|32|16|8) (Const(64|32|16|8) [1]) (Com(64|32|16|8) x)) -> (Neg(64|32|16|8) x)
+
+(And(64|32|16|8) x (And(64|32|16|8) x y)) -> (And(64|32|16|8) x y)
+(Or(64|32|16|8) x (Or(64|32|16|8) x y)) -> (Or(64|32|16|8) x y)
 (Xor(64|32|16|8) x (Xor(64|32|16|8) x y)) -> y
 
 // Ands clear bits. Ors set bits.