Commit f6f1750a authored by Alberto Donizetti's avatar Alberto Donizetti Committed by Brad Fitzpatrick

cmd/compile: use | in the most repetitive boolean rules

For now, limited to a few repetitive boolean rules where the win is
substantial (4+ variants).

Change-Id: I67bce0d356ca7d71a0f15ff98551fe2caff8abf9
Reviewed-on: https://go-review.googlesource.com/95535
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 0a4c439d
......@@ -239,18 +239,12 @@
(IsSliceInBounds (Const64 [c]) (Const64 [d])) -> (ConstBool [b2i(0 <= c && c <= d)])
(IsSliceInBounds (SliceLen x) (SliceCap x)) -> (ConstBool [1])
(Eq64 x x) -> (ConstBool [1])
(Eq32 x x) -> (ConstBool [1])
(Eq16 x x) -> (ConstBool [1])
(Eq8 x x) -> (ConstBool [1])
(Eq(64|32|16|8) x x) -> (ConstBool [1])
(EqB (ConstBool [c]) (ConstBool [d])) -> (ConstBool [b2i(c == d)])
(EqB (ConstBool [0]) x) -> (Not x)
(EqB (ConstBool [1]) x) -> x
(Neq64 x x) -> (ConstBool [0])
(Neq32 x x) -> (ConstBool [0])
(Neq16 x x) -> (ConstBool [0])
(Neq8 x x) -> (ConstBool [0])
(Neq(64|32|16|8) x x) -> (ConstBool [0])
(NeqB (ConstBool [c]) (ConstBool [d])) -> (ConstBool [b2i(c != d)])
(NeqB (ConstBool [0]) x) -> x
(NeqB (ConstBool [1]) x) -> (Not x)
......@@ -273,57 +267,19 @@
(Sub8 x (Const8 <t> [c])) && x.Op != OpConst8 -> (Add8 (Const8 <t> [int64(int8(-c))]) x)
// fold negation into comparison operators
(Not (Eq64 x y)) -> (Neq64 x y)
(Not (Eq32 x y)) -> (Neq32 x y)
(Not (Eq16 x y)) -> (Neq16 x y)
(Not (Eq8 x y)) -> (Neq8 x y)
(Not (EqB x y)) -> (NeqB x y)
(Not (Neq64 x y)) -> (Eq64 x y)
(Not (Neq32 x y)) -> (Eq32 x y)
(Not (Neq16 x y)) -> (Eq16 x y)
(Not (Neq8 x y)) -> (Eq8 x y)
(Not (NeqB x y)) -> (EqB x y)
(Not (Greater64 x y)) -> (Leq64 x y)
(Not (Greater32 x y)) -> (Leq32 x y)
(Not (Greater16 x y)) -> (Leq16 x y)
(Not (Greater8 x y)) -> (Leq8 x y)
(Not (Greater64U x y)) -> (Leq64U x y)
(Not (Greater32U x y)) -> (Leq32U x y)
(Not (Greater16U x y)) -> (Leq16U x y)
(Not (Greater8U x y)) -> (Leq8U x y)
(Not (Geq64 x y)) -> (Less64 x y)
(Not (Geq32 x y)) -> (Less32 x y)
(Not (Geq16 x y)) -> (Less16 x y)
(Not (Geq8 x y)) -> (Less8 x y)
(Not (Geq64U x y)) -> (Less64U x y)
(Not (Geq32U x y)) -> (Less32U x y)
(Not (Geq16U x y)) -> (Less16U x y)
(Not (Geq8U x y)) -> (Less8U x y)
(Not (Less64 x y)) -> (Geq64 x y)
(Not (Less32 x y)) -> (Geq32 x y)
(Not (Less16 x y)) -> (Geq16 x y)
(Not (Less8 x y)) -> (Geq8 x y)
(Not (Less64U x y)) -> (Geq64U x y)
(Not (Less32U x y)) -> (Geq32U x y)
(Not (Less16U x y)) -> (Geq16U x y)
(Not (Less8U x y)) -> (Geq8U x y)
(Not (Leq64 x y)) -> (Greater64 x y)
(Not (Leq32 x y)) -> (Greater32 x y)
(Not (Leq16 x y)) -> (Greater16 x y)
(Not (Leq8 x y)) -> (Greater8 x y)
(Not (Leq64U x y)) -> (Greater64U x y)
(Not (Leq32U x y)) -> (Greater32U x y)
(Not (Leq16U x y)) -> (Greater16U x y)
(Not (Leq8U x y)) -> (Greater8U x y)
(Not (Eq(64|32|16|8|B) x y)) -> (Neq(64|32|16|8|B) x y)
(Not (Neq(64|32|16|8|B) x y)) -> (Eq(64|32|16|8|B) x y)
(Not (Greater(64|32|16|8) x y)) -> (Leq(64|32|16|8) x y)
(Not (Greater(64|32|16|8)U x y)) -> (Leq(64|32|16|8)U x y)
(Not (Geq(64|32|16|8) x y)) -> (Less(64|32|16|8) x y)
(Not (Geq(64|32|16|8)U x y)) -> (Less(64|32|16|8)U x y)
(Not (Less(64|32|16|8) x y)) -> (Geq(64|32|16|8) x y)
(Not (Less(64|32|16|8)U x y)) -> (Geq(64|32|16|8)U x y)
(Not (Leq(64|32|16|8) x y)) -> (Greater(64|32|16|8) x y)
(Not (Leq(64|32|16|8)U x y)) -> (Greater(64|32|16|8)U x y)
// Distribute multiplication c * (d+x) -> c*d + c*x. Useful for:
// a[i].b = ...; a[i+1].b = ...
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment