Commit 991036ae authored by Todd Neal's avatar Todd Neal

[dev.ssa] cmd/compile: store bools in AuxInt

Store bools in AuxInt to reduce allocations.

Change-Id: Ibd26db67fca5e1e2803f53d7ef094897968b704b
Reviewed-on: https://go-review.googlesource.com/14276Reviewed-by: default avatarKeith Randall <khr@golang.org>
parent d9f2cafb
...@@ -302,6 +302,11 @@ func (s *state) newValue0A(op ssa.Op, t ssa.Type, aux interface{}) *ssa.Value { ...@@ -302,6 +302,11 @@ func (s *state) newValue0A(op ssa.Op, t ssa.Type, aux interface{}) *ssa.Value {
return s.curBlock.NewValue0A(s.peekLine(), op, t, aux) return s.curBlock.NewValue0A(s.peekLine(), op, t, aux)
} }
// newValue0I adds a new value with no arguments and an auxint value to the current block.
func (s *state) newValue0I(op ssa.Op, t ssa.Type, auxint int64) *ssa.Value {
return s.curBlock.NewValue0I(s.peekLine(), op, t, auxint)
}
// newValue1 adds a new value with one argument to the current block. // newValue1 adds a new value with one argument to the current block.
func (s *state) newValue1(op ssa.Op, t ssa.Type, arg *ssa.Value) *ssa.Value { func (s *state) newValue1(op ssa.Op, t ssa.Type, arg *ssa.Value) *ssa.Value {
return s.curBlock.NewValue1(s.peekLine(), op, t, arg) return s.curBlock.NewValue1(s.peekLine(), op, t, arg)
...@@ -337,16 +342,21 @@ func (s *state) newValue3I(op ssa.Op, t ssa.Type, aux int64, arg0, arg1, arg2 *s ...@@ -337,16 +342,21 @@ func (s *state) newValue3I(op ssa.Op, t ssa.Type, aux int64, arg0, arg1, arg2 *s
return s.curBlock.NewValue3I(s.peekLine(), op, t, aux, arg0, arg1, arg2) return s.curBlock.NewValue3I(s.peekLine(), op, t, aux, arg0, arg1, arg2)
} }
// entryNewValue adds a new value with no arguments to the entry block. // entryNewValue0 adds a new value with no arguments to the entry block.
func (s *state) entryNewValue0(op ssa.Op, t ssa.Type) *ssa.Value { func (s *state) entryNewValue0(op ssa.Op, t ssa.Type) *ssa.Value {
return s.f.Entry.NewValue0(s.peekLine(), op, t) return s.f.Entry.NewValue0(s.peekLine(), op, t)
} }
// entryNewValue adds a new value with no arguments and an aux value to the entry block. // entryNewValue0A adds a new value with no arguments and an aux value to the entry block.
func (s *state) entryNewValue0A(op ssa.Op, t ssa.Type, aux interface{}) *ssa.Value { func (s *state) entryNewValue0A(op ssa.Op, t ssa.Type, aux interface{}) *ssa.Value {
return s.f.Entry.NewValue0A(s.peekLine(), op, t, aux) return s.f.Entry.NewValue0A(s.peekLine(), op, t, aux)
} }
// entryNewValue0I adds a new value with no arguments and an auxint value to the entry block.
func (s *state) entryNewValue0I(op ssa.Op, t ssa.Type, auxint int64) *ssa.Value {
return s.f.Entry.NewValue0I(s.peekLine(), op, t, auxint)
}
// entryNewValue1 adds a new value with one argument to the entry block. // entryNewValue1 adds a new value with one argument to the entry block.
func (s *state) entryNewValue1(op ssa.Op, t ssa.Type, arg *ssa.Value) *ssa.Value { func (s *state) entryNewValue1(op ssa.Op, t ssa.Type, arg *ssa.Value) *ssa.Value {
return s.f.Entry.NewValue1(s.peekLine(), op, t, arg) return s.f.Entry.NewValue1(s.peekLine(), op, t, arg)
...@@ -635,7 +645,7 @@ func (s *state) stmt(n *Node) { ...@@ -635,7 +645,7 @@ func (s *state) stmt(n *Node) {
if n.Left != nil { if n.Left != nil {
cond = s.expr(n.Left) cond = s.expr(n.Left)
} else { } else {
cond = s.entryNewValue0A(ssa.OpConstBool, Types[TBOOL], true) cond = s.entryNewValue0I(ssa.OpConstBool, Types[TBOOL], 1) // 1 = true
} }
b = s.endBlock() b = s.endBlock()
b.Kind = ssa.BlockIf b.Kind = ssa.BlockIf
...@@ -1103,7 +1113,11 @@ func (s *state) expr(n *Node) *ssa.Value { ...@@ -1103,7 +1113,11 @@ func (s *state) expr(n *Node) *ssa.Value {
case CTSTR: case CTSTR:
return s.entryNewValue0A(ssa.OpConstString, n.Type, n.Val().U) return s.entryNewValue0A(ssa.OpConstString, n.Type, n.Val().U)
case CTBOOL: case CTBOOL:
return s.entryNewValue0A(ssa.OpConstBool, n.Type, n.Val().U) if n.Val().U.(bool) {
return s.entryNewValue0I(ssa.OpConstBool, n.Type, 1) // 1 = true
} else {
return s.entryNewValue0I(ssa.OpConstBool, n.Type, 0) // 0 = false
}
case CTNIL: case CTNIL:
t := n.Type t := n.Type
switch { switch {
...@@ -1882,7 +1896,7 @@ func (s *state) zeroVal(t *Type) *ssa.Value { ...@@ -1882,7 +1896,7 @@ func (s *state) zeroVal(t *Type) *ssa.Value {
case t.IsPtr(): case t.IsPtr():
return s.entryNewValue0(ssa.OpConstNil, t) return s.entryNewValue0(ssa.OpConstNil, t)
case t.IsBoolean(): case t.IsBoolean():
return s.entryNewValue0A(ssa.OpConstBool, t, false) // TODO: store bools as 0/1 in AuxInt? return s.entryNewValue0I(ssa.OpConstBool, t, 0) // 0 = false
case t.IsInterface(): case t.IsInterface():
return s.entryNewValue0(ssa.OpConstInterface, t) return s.entryNewValue0(ssa.OpConstInterface, t)
case t.IsSlice(): case t.IsSlice():
......
...@@ -122,6 +122,11 @@ func checkFunc(f *Func) { ...@@ -122,6 +122,11 @@ func checkFunc(f *Func) {
} }
for _, v := range b.Values { for _, v := range b.Values {
if _, ok := v.Aux.(bool); ok {
f.Fatalf("value %v has a bool Aux value, should be AuxInt", v.LongString())
}
for _, arg := range v.Args { for _, arg := range v.Args {
if arg == nil { if arg == nil {
f.Fatalf("value %v has nil arg", v.LongString()) f.Fatalf("value %v has nil arg", v.LongString())
......
...@@ -17,7 +17,7 @@ func TestDeadLoop(t *testing.T) { ...@@ -17,7 +17,7 @@ func TestDeadLoop(t *testing.T) {
// dead loop // dead loop
Bloc("deadblock", Bloc("deadblock",
// dead value in dead block // dead value in dead block
Valu("deadval", OpConstBool, TypeBool, 0, true), Valu("deadval", OpConstBool, TypeBool, 1, nil),
If("deadval", "deadblock", "exit"))) If("deadval", "deadblock", "exit")))
CheckFunc(fun.f) CheckFunc(fun.f)
...@@ -63,7 +63,7 @@ func TestNeverTaken(t *testing.T) { ...@@ -63,7 +63,7 @@ func TestNeverTaken(t *testing.T) {
c := testConfig(t) c := testConfig(t)
fun := Fun(c, "entry", fun := Fun(c, "entry",
Bloc("entry", Bloc("entry",
Valu("cond", OpConstBool, TypeBool, 0, false), Valu("cond", OpConstBool, TypeBool, 0, nil),
Valu("mem", OpArg, TypeMem, 0, ".mem"), Valu("mem", OpArg, TypeMem, 0, ".mem"),
If("cond", "then", "else")), If("cond", "then", "else")),
Bloc("then", Bloc("then",
...@@ -99,7 +99,7 @@ func TestNestedDeadBlocks(t *testing.T) { ...@@ -99,7 +99,7 @@ func TestNestedDeadBlocks(t *testing.T) {
fun := Fun(c, "entry", fun := Fun(c, "entry",
Bloc("entry", Bloc("entry",
Valu("mem", OpArg, TypeMem, 0, ".mem"), Valu("mem", OpArg, TypeMem, 0, ".mem"),
Valu("cond", OpConstBool, TypeBool, 0, false), Valu("cond", OpConstBool, TypeBool, 0, nil),
If("cond", "b2", "b4")), If("cond", "b2", "b4")),
Bloc("b2", Bloc("b2",
If("cond", "b3", "b4")), If("cond", "b3", "b4")),
......
...@@ -14,7 +14,7 @@ func TestDeadStore(t *testing.T) { ...@@ -14,7 +14,7 @@ func TestDeadStore(t *testing.T) {
Bloc("entry", Bloc("entry",
Valu("start", OpArg, TypeMem, 0, ".mem"), Valu("start", OpArg, TypeMem, 0, ".mem"),
Valu("sb", OpSB, TypeInvalid, 0, nil), Valu("sb", OpSB, TypeInvalid, 0, nil),
Valu("v", OpConstBool, TypeBool, 0, true), Valu("v", OpConstBool, TypeBool, 1, nil),
Valu("addr1", OpAddr, ptrType, 0, nil, "sb"), Valu("addr1", OpAddr, ptrType, 0, nil, "sb"),
Valu("addr2", OpAddr, ptrType, 0, nil, "sb"), Valu("addr2", OpAddr, ptrType, 0, nil, "sb"),
Valu("addr3", OpAddr, ptrType, 0, nil, "sb"), Valu("addr3", OpAddr, ptrType, 0, nil, "sb"),
...@@ -49,7 +49,7 @@ func TestDeadStorePhi(t *testing.T) { ...@@ -49,7 +49,7 @@ func TestDeadStorePhi(t *testing.T) {
Bloc("entry", Bloc("entry",
Valu("start", OpArg, TypeMem, 0, ".mem"), Valu("start", OpArg, TypeMem, 0, ".mem"),
Valu("sb", OpSB, TypeInvalid, 0, nil), Valu("sb", OpSB, TypeInvalid, 0, nil),
Valu("v", OpConstBool, TypeBool, 0, true), Valu("v", OpConstBool, TypeBool, 1, nil),
Valu("addr", OpAddr, ptrType, 0, nil, "sb"), Valu("addr", OpAddr, ptrType, 0, nil, "sb"),
Goto("loop")), Goto("loop")),
Bloc("loop", Bloc("loop",
...@@ -76,7 +76,7 @@ func TestDeadStoreTypes(t *testing.T) { ...@@ -76,7 +76,7 @@ func TestDeadStoreTypes(t *testing.T) {
Bloc("entry", Bloc("entry",
Valu("start", OpArg, TypeMem, 0, ".mem"), Valu("start", OpArg, TypeMem, 0, ".mem"),
Valu("sb", OpSB, TypeInvalid, 0, nil), Valu("sb", OpSB, TypeInvalid, 0, nil),
Valu("v", OpConstBool, TypeBool, 0, true), Valu("v", OpConstBool, TypeBool, 1, nil),
Valu("addr1", OpAddr, t1, 0, nil, "sb"), Valu("addr1", OpAddr, t1, 0, nil, "sb"),
Valu("addr2", OpAddr, t2, 0, nil, "sb"), Valu("addr2", OpAddr, t2, 0, nil, "sb"),
Valu("store1", OpStore, TypeMem, 1, nil, "addr1", "v", "start"), Valu("store1", OpStore, TypeMem, 1, nil, "addr1", "v", "start"),
......
...@@ -44,7 +44,7 @@ func genFwdBack(size int) []bloc { ...@@ -44,7 +44,7 @@ func genFwdBack(size int) []bloc {
blocs = append(blocs, blocs = append(blocs,
Bloc("entry", Bloc("entry",
Valu("mem", OpArg, TypeMem, 0, ".mem"), Valu("mem", OpArg, TypeMem, 0, ".mem"),
Valu("p", OpConstBool, TypeBool, 0, true), Valu("p", OpConstBool, TypeBool, 1, nil),
Goto(blockn(0)), Goto(blockn(0)),
), ),
) )
...@@ -74,7 +74,7 @@ func genManyPred(size int) []bloc { ...@@ -74,7 +74,7 @@ func genManyPred(size int) []bloc {
blocs = append(blocs, blocs = append(blocs,
Bloc("entry", Bloc("entry",
Valu("mem", OpArg, TypeMem, 0, ".mem"), Valu("mem", OpArg, TypeMem, 0, ".mem"),
Valu("p", OpConstBool, TypeBool, 0, true), Valu("p", OpConstBool, TypeBool, 1, nil),
Goto(blockn(0)), Goto(blockn(0)),
), ),
) )
...@@ -85,15 +85,15 @@ func genManyPred(size int) []bloc { ...@@ -85,15 +85,15 @@ func genManyPred(size int) []bloc {
switch i % 3 { switch i % 3 {
case 0: case 0:
blocs = append(blocs, Bloc(blockn(i), blocs = append(blocs, Bloc(blockn(i),
Valu("a", OpConstBool, TypeBool, 0, true), Valu("a", OpConstBool, TypeBool, 1, nil),
Goto(blockn(i+1)))) Goto(blockn(i+1))))
case 1: case 1:
blocs = append(blocs, Bloc(blockn(i), blocs = append(blocs, Bloc(blockn(i),
Valu("a", OpConstBool, TypeBool, 0, true), Valu("a", OpConstBool, TypeBool, 1, nil),
If("p", blockn(i+1), blockn(0)))) If("p", blockn(i+1), blockn(0))))
case 2: case 2:
blocs = append(blocs, Bloc(blockn(i), blocs = append(blocs, Bloc(blockn(i),
Valu("a", OpConstBool, TypeBool, 0, true), Valu("a", OpConstBool, TypeBool, 1, nil),
If("p", blockn(i+1), blockn(size)))) If("p", blockn(i+1), blockn(size))))
} }
} }
...@@ -112,7 +112,7 @@ func genMaxPred(size int) []bloc { ...@@ -112,7 +112,7 @@ func genMaxPred(size int) []bloc {
blocs = append(blocs, blocs = append(blocs,
Bloc("entry", Bloc("entry",
Valu("mem", OpArg, TypeMem, 0, ".mem"), Valu("mem", OpArg, TypeMem, 0, ".mem"),
Valu("p", OpConstBool, TypeBool, 0, true), Valu("p", OpConstBool, TypeBool, 1, nil),
Goto(blockn(0)), Goto(blockn(0)),
), ),
) )
...@@ -137,14 +137,14 @@ func genMaxPredValue(size int) []bloc { ...@@ -137,14 +137,14 @@ func genMaxPredValue(size int) []bloc {
blocs = append(blocs, blocs = append(blocs,
Bloc("entry", Bloc("entry",
Valu("mem", OpArg, TypeMem, 0, ".mem"), Valu("mem", OpArg, TypeMem, 0, ".mem"),
Valu("p", OpConstBool, TypeBool, 0, true), Valu("p", OpConstBool, TypeBool, 1, nil),
Goto(blockn(0)), Goto(blockn(0)),
), ),
) )
for i := 0; i < size; i++ { for i := 0; i < size; i++ {
blocs = append(blocs, Bloc(blockn(i), blocs = append(blocs, Bloc(blockn(i),
Valu("a", OpConstBool, TypeBool, 0, true), Valu("a", OpConstBool, TypeBool, 1, nil),
If("p", blockn(i+1), "exit"))) If("p", blockn(i+1), "exit")))
} }
...@@ -267,7 +267,7 @@ func TestDominatorsMultPredFwd(t *testing.T) { ...@@ -267,7 +267,7 @@ func TestDominatorsMultPredFwd(t *testing.T) {
fun := Fun(c, "entry", fun := Fun(c, "entry",
Bloc("entry", Bloc("entry",
Valu("mem", OpArg, TypeMem, 0, ".mem"), Valu("mem", OpArg, TypeMem, 0, ".mem"),
Valu("p", OpConstBool, TypeBool, 0, true), Valu("p", OpConstBool, TypeBool, 1, nil),
If("p", "a", "c")), If("p", "a", "c")),
Bloc("a", Bloc("a",
If("p", "b", "c")), If("p", "b", "c")),
...@@ -295,7 +295,7 @@ func TestDominatorsDeadCode(t *testing.T) { ...@@ -295,7 +295,7 @@ func TestDominatorsDeadCode(t *testing.T) {
fun := Fun(c, "entry", fun := Fun(c, "entry",
Bloc("entry", Bloc("entry",
Valu("mem", OpArg, TypeMem, 0, ".mem"), Valu("mem", OpArg, TypeMem, 0, ".mem"),
Valu("p", OpConstBool, TypeBool, 0, false), Valu("p", OpConstBool, TypeBool, 0, nil),
If("p", "b3", "b5")), If("p", "b3", "b5")),
Bloc("b2", Exit("mem")), Bloc("b2", Exit("mem")),
Bloc("b3", Goto("b2")), Bloc("b3", Goto("b2")),
...@@ -320,7 +320,7 @@ func TestDominatorsMultPredRev(t *testing.T) { ...@@ -320,7 +320,7 @@ func TestDominatorsMultPredRev(t *testing.T) {
Goto("first")), Goto("first")),
Bloc("first", Bloc("first",
Valu("mem", OpArg, TypeMem, 0, ".mem"), Valu("mem", OpArg, TypeMem, 0, ".mem"),
Valu("p", OpConstBool, TypeBool, 0, true), Valu("p", OpConstBool, TypeBool, 1, nil),
Goto("a")), Goto("a")),
Bloc("a", Bloc("a",
If("p", "b", "first")), If("p", "b", "first")),
...@@ -349,7 +349,7 @@ func TestDominatorsMultPred(t *testing.T) { ...@@ -349,7 +349,7 @@ func TestDominatorsMultPred(t *testing.T) {
fun := Fun(c, "entry", fun := Fun(c, "entry",
Bloc("entry", Bloc("entry",
Valu("mem", OpArg, TypeMem, 0, ".mem"), Valu("mem", OpArg, TypeMem, 0, ".mem"),
Valu("p", OpConstBool, TypeBool, 0, true), Valu("p", OpConstBool, TypeBool, 1, nil),
If("p", "a", "c")), If("p", "a", "c")),
Bloc("a", Bloc("a",
If("p", "b", "c")), If("p", "b", "c")),
...@@ -377,7 +377,7 @@ func TestPostDominators(t *testing.T) { ...@@ -377,7 +377,7 @@ func TestPostDominators(t *testing.T) {
fun := Fun(c, "entry", fun := Fun(c, "entry",
Bloc("entry", Bloc("entry",
Valu("mem", OpArg, TypeMem, 0, ".mem"), Valu("mem", OpArg, TypeMem, 0, ".mem"),
Valu("p", OpConstBool, TypeBool, 0, true), Valu("p", OpConstBool, TypeBool, 1, nil),
If("p", "a", "c")), If("p", "a", "c")),
Bloc("a", Bloc("a",
If("p", "b", "c")), If("p", "b", "c")),
...@@ -404,7 +404,7 @@ func TestInfiniteLoop(t *testing.T) { ...@@ -404,7 +404,7 @@ func TestInfiniteLoop(t *testing.T) {
fun := Fun(c, "entry", fun := Fun(c, "entry",
Bloc("entry", Bloc("entry",
Valu("mem", OpArg, TypeMem, 0, ".mem"), Valu("mem", OpArg, TypeMem, 0, ".mem"),
Valu("p", OpConstBool, TypeBool, 0, true), Valu("p", OpConstBool, TypeBool, 1, nil),
Goto("a")), Goto("a")),
Bloc("a", Bloc("a",
Goto("b")), Goto("b")),
......
...@@ -303,8 +303,7 @@ ...@@ -303,8 +303,7 @@
(Const64F {val}) -> (MOVSDconst {val}) (Const64F {val}) -> (MOVSDconst {val})
(ConstPtr [val]) -> (MOVQconst [val]) (ConstPtr [val]) -> (MOVQconst [val])
(ConstNil) -> (MOVQconst [0]) (ConstNil) -> (MOVQconst [0])
(ConstBool {b}) && !b.(bool) -> (MOVBconst [0]) (ConstBool [b]) -> (MOVBconst [b])
(ConstBool {b}) && b.(bool) -> (MOVBconst [1])
(Addr {sym} base) -> (LEAQ {sym} base) (Addr {sym} base) -> (LEAQ {sym} base)
......
...@@ -24,18 +24,18 @@ ...@@ -24,18 +24,18 @@
(AddPtr (ConstPtr [c]) (ConstPtr [d])) -> (ConstPtr [c+d]) (AddPtr (ConstPtr [c]) (ConstPtr [d])) -> (ConstPtr [c+d])
(Mul64 (Const64 [c]) (Const64 [d])) -> (Const64 [c*d]) (Mul64 (Const64 [c]) (Const64 [d])) -> (Const64 [c*d])
(MulPtr (ConstPtr [c]) (ConstPtr [d])) -> (ConstPtr [c*d]) (MulPtr (ConstPtr [c]) (ConstPtr [d])) -> (ConstPtr [c*d])
(IsInBounds (Const32 [c]) (Const32 [d])) -> (ConstBool {inBounds32(c,d)}) (IsInBounds (Const32 [c]) (Const32 [d])) -> (ConstBool [b2i(inBounds32(c,d))])
(IsInBounds (Const64 [c]) (Const64 [d])) -> (ConstBool {inBounds64(c,d)}) (IsInBounds (Const64 [c]) (Const64 [d])) -> (ConstBool [b2i(inBounds64(c,d))])
(IsInBounds (ConstPtr [c]) (ConstPtr [d])) && config.PtrSize == 4 -> (ConstBool {inBounds32(c,d)}) (IsInBounds (ConstPtr [c]) (ConstPtr [d])) && config.PtrSize == 4 -> (ConstBool [b2i(inBounds32(c,d))])
(IsInBounds (ConstPtr [c]) (ConstPtr [d])) && config.PtrSize == 8 -> (ConstBool {inBounds64(c,d)}) (IsInBounds (ConstPtr [c]) (ConstPtr [d])) && config.PtrSize == 8 -> (ConstBool [b2i(inBounds64(c,d))])
(Eq64 x x) -> (ConstBool {true}) (Eq64 x x) -> (ConstBool [1])
(Eq32 x x) -> (ConstBool {true}) (Eq32 x x) -> (ConstBool [1])
(Eq16 x x) -> (ConstBool {true}) (Eq16 x x) -> (ConstBool [1])
(Eq8 x x) -> (ConstBool {true}) (Eq8 x x) -> (ConstBool [1])
(Neq64 x x) -> (ConstBool {false}) (Neq64 x x) -> (ConstBool [0])
(Neq32 x x) -> (ConstBool {false}) (Neq32 x x) -> (ConstBool [0])
(Neq16 x x) -> (ConstBool {false}) (Neq16 x x) -> (ConstBool [0])
(Neq8 x x) -> (ConstBool {false}) (Neq8 x x) -> (ConstBool [0])
// simplifications // simplifications
(Or64 x x) -> x (Or64 x x) -> x
...@@ -177,5 +177,5 @@ ...@@ -177,5 +177,5 @@
(If (IsNonNil (GetG)) yes no) -> (First nil yes no) (If (IsNonNil (GetG)) yes no) -> (First nil yes no)
(If (Not cond) yes no) -> (If cond no yes) (If (Not cond) yes no) -> (If cond no yes)
(If (ConstBool {c}) yes no) && c.(bool) -> (First nil yes no) (If (ConstBool [c]) yes no) && c == 1 -> (First nil yes no)
(If (ConstBool {c}) yes no) && !c.(bool) -> (First nil no yes) (If (ConstBool [c]) yes no) && c == 0 -> (First nil no yes)
...@@ -162,3 +162,11 @@ func isPowerOfTwo(n int64) bool { ...@@ -162,3 +162,11 @@ func isPowerOfTwo(n int64) bool {
func is32Bit(n int64) bool { func is32Bit(n int64) bool {
return n == int64(int32(n)) return n == int64(int32(n))
} }
// b2i translates a boolean value to 0 or 1 for assigning to auxInt.
func b2i(b bool) int64 {
if b {
return 1
}
return 0
}
...@@ -1624,41 +1624,20 @@ func rewriteValueAMD64(v *Value, config *Config) bool { ...@@ -1624,41 +1624,20 @@ func rewriteValueAMD64(v *Value, config *Config) bool {
end200524c722ed14ca935ba47f8f30327d: end200524c722ed14ca935ba47f8f30327d:
; ;
case OpConstBool: case OpConstBool:
// match: (ConstBool {b}) // match: (ConstBool [b])
// cond: !b.(bool) // cond:
// result: (MOVBconst [0]) // result: (MOVBconst [b])
{
b := v.Aux
if !(!b.(bool)) {
goto end876159ea073d2dcefcc251667c1a7780
}
v.Op = OpAMD64MOVBconst
v.AuxInt = 0
v.Aux = nil
v.resetArgs()
v.AuxInt = 0
return true
}
goto end876159ea073d2dcefcc251667c1a7780
end876159ea073d2dcefcc251667c1a7780:
;
// match: (ConstBool {b})
// cond: b.(bool)
// result: (MOVBconst [1])
{ {
b := v.Aux b := v.AuxInt
if !(b.(bool)) {
goto end0dacad3f7cad53905aad5303391447f6
}
v.Op = OpAMD64MOVBconst v.Op = OpAMD64MOVBconst
v.AuxInt = 0 v.AuxInt = 0
v.Aux = nil v.Aux = nil
v.resetArgs() v.resetArgs()
v.AuxInt = 1 v.AuxInt = b
return true return true
} }
goto end0dacad3f7cad53905aad5303391447f6 goto end6d919011283330dcbcb3826f0adc6793
end0dacad3f7cad53905aad5303391447f6: end6d919011283330dcbcb3826f0adc6793:
; ;
case OpConstNil: case OpConstNil:
// match: (ConstNil) // match: (ConstNil)
......
...@@ -354,78 +354,78 @@ func rewriteValuegeneric(v *Value, config *Config) bool { ...@@ -354,78 +354,78 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
case OpEq16: case OpEq16:
// match: (Eq16 x x) // match: (Eq16 x x)
// cond: // cond:
// result: (ConstBool {true}) // result: (ConstBool [1])
{ {
x := v.Args[0] x := v.Args[0]
if v.Args[1] != x { if v.Args[1] != x {
goto enda503589f9b617e708a5ad3ddb047809f goto end0c0fe5fdfba3821add3448fd3f1fc6b7
} }
v.Op = OpConstBool v.Op = OpConstBool
v.AuxInt = 0 v.AuxInt = 0
v.Aux = nil v.Aux = nil
v.resetArgs() v.resetArgs()
v.Aux = true v.AuxInt = 1
return true return true
} }
goto enda503589f9b617e708a5ad3ddb047809f goto end0c0fe5fdfba3821add3448fd3f1fc6b7
enda503589f9b617e708a5ad3ddb047809f: end0c0fe5fdfba3821add3448fd3f1fc6b7:
; ;
case OpEq32: case OpEq32:
// match: (Eq32 x x) // match: (Eq32 x x)
// cond: // cond:
// result: (ConstBool {true}) // result: (ConstBool [1])
{ {
x := v.Args[0] x := v.Args[0]
if v.Args[1] != x { if v.Args[1] != x {
goto endc94ae3b97d0090257b02152e437b3e17 goto end6da547ec4ee93d787434f3bda873e4a0
} }
v.Op = OpConstBool v.Op = OpConstBool
v.AuxInt = 0 v.AuxInt = 0
v.Aux = nil v.Aux = nil
v.resetArgs() v.resetArgs()
v.Aux = true v.AuxInt = 1
return true return true
} }
goto endc94ae3b97d0090257b02152e437b3e17 goto end6da547ec4ee93d787434f3bda873e4a0
endc94ae3b97d0090257b02152e437b3e17: end6da547ec4ee93d787434f3bda873e4a0:
; ;
case OpEq64: case OpEq64:
// match: (Eq64 x x) // match: (Eq64 x x)
// cond: // cond:
// result: (ConstBool {true}) // result: (ConstBool [1])
{ {
x := v.Args[0] x := v.Args[0]
if v.Args[1] != x { if v.Args[1] != x {
goto end4d21cead60174989467a9c8202dbb91d goto endb1d471cc503ba8bb05440f01dbf33d81
} }
v.Op = OpConstBool v.Op = OpConstBool
v.AuxInt = 0 v.AuxInt = 0
v.Aux = nil v.Aux = nil
v.resetArgs() v.resetArgs()
v.Aux = true v.AuxInt = 1
return true return true
} }
goto end4d21cead60174989467a9c8202dbb91d goto endb1d471cc503ba8bb05440f01dbf33d81
end4d21cead60174989467a9c8202dbb91d: endb1d471cc503ba8bb05440f01dbf33d81:
; ;
case OpEq8: case OpEq8:
// match: (Eq8 x x) // match: (Eq8 x x)
// cond: // cond:
// result: (ConstBool {true}) // result: (ConstBool [1])
{ {
x := v.Args[0] x := v.Args[0]
if v.Args[1] != x { if v.Args[1] != x {
goto end73dce8bba164e4f4a1dd701bf8cfb362 goto enda66da0d3e7e51624ee46527727c48a9a
} }
v.Op = OpConstBool v.Op = OpConstBool
v.AuxInt = 0 v.AuxInt = 0
v.Aux = nil v.Aux = nil
v.resetArgs() v.resetArgs()
v.Aux = true v.AuxInt = 1
return true return true
} }
goto end73dce8bba164e4f4a1dd701bf8cfb362 goto enda66da0d3e7e51624ee46527727c48a9a
end73dce8bba164e4f4a1dd701bf8cfb362: enda66da0d3e7e51624ee46527727c48a9a:
; ;
case OpEqFat: case OpEqFat:
// match: (EqFat x y) // match: (EqFat x y)
...@@ -521,97 +521,97 @@ func rewriteValuegeneric(v *Value, config *Config) bool { ...@@ -521,97 +521,97 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
case OpIsInBounds: case OpIsInBounds:
// match: (IsInBounds (Const32 [c]) (Const32 [d])) // match: (IsInBounds (Const32 [c]) (Const32 [d]))
// cond: // cond:
// result: (ConstBool {inBounds32(c,d)}) // result: (ConstBool [b2i(inBounds32(c,d))])
{ {
if v.Args[0].Op != OpConst32 { if v.Args[0].Op != OpConst32 {
goto endc3396bf88b56276e1691abe62811dba5 goto endf0a2ecfe84b293de6ff0919e45d19d9d
} }
c := v.Args[0].AuxInt c := v.Args[0].AuxInt
if v.Args[1].Op != OpConst32 { if v.Args[1].Op != OpConst32 {
goto endc3396bf88b56276e1691abe62811dba5 goto endf0a2ecfe84b293de6ff0919e45d19d9d
} }
d := v.Args[1].AuxInt d := v.Args[1].AuxInt
v.Op = OpConstBool v.Op = OpConstBool
v.AuxInt = 0 v.AuxInt = 0
v.Aux = nil v.Aux = nil
v.resetArgs() v.resetArgs()
v.Aux = inBounds32(c, d) v.AuxInt = b2i(inBounds32(c, d))
return true return true
} }
goto endc3396bf88b56276e1691abe62811dba5 goto endf0a2ecfe84b293de6ff0919e45d19d9d
endc3396bf88b56276e1691abe62811dba5: endf0a2ecfe84b293de6ff0919e45d19d9d:
; ;
// match: (IsInBounds (Const64 [c]) (Const64 [d])) // match: (IsInBounds (Const64 [c]) (Const64 [d]))
// cond: // cond:
// result: (ConstBool {inBounds64(c,d)}) // result: (ConstBool [b2i(inBounds64(c,d))])
{ {
if v.Args[0].Op != OpConst64 { if v.Args[0].Op != OpConst64 {
goto end0b4b8178a54662835b00bfa503cf879a goto end4b406f402c135f50f71effcc904ecb2b
} }
c := v.Args[0].AuxInt c := v.Args[0].AuxInt
if v.Args[1].Op != OpConst64 { if v.Args[1].Op != OpConst64 {
goto end0b4b8178a54662835b00bfa503cf879a goto end4b406f402c135f50f71effcc904ecb2b
} }
d := v.Args[1].AuxInt d := v.Args[1].AuxInt
v.Op = OpConstBool v.Op = OpConstBool
v.AuxInt = 0 v.AuxInt = 0
v.Aux = nil v.Aux = nil
v.resetArgs() v.resetArgs()
v.Aux = inBounds64(c, d) v.AuxInt = b2i(inBounds64(c, d))
return true return true
} }
goto end0b4b8178a54662835b00bfa503cf879a goto end4b406f402c135f50f71effcc904ecb2b
end0b4b8178a54662835b00bfa503cf879a: end4b406f402c135f50f71effcc904ecb2b:
; ;
// match: (IsInBounds (ConstPtr [c]) (ConstPtr [d])) // match: (IsInBounds (ConstPtr [c]) (ConstPtr [d]))
// cond: config.PtrSize == 4 // cond: config.PtrSize == 4
// result: (ConstBool {inBounds32(c,d)}) // result: (ConstBool [b2i(inBounds32(c,d))])
{ {
if v.Args[0].Op != OpConstPtr { if v.Args[0].Op != OpConstPtr {
goto end2c6938f68a67e08dbd96edb1e693e549 goto end4323278ec7a053034fcf7033697d7b3b
} }
c := v.Args[0].AuxInt c := v.Args[0].AuxInt
if v.Args[1].Op != OpConstPtr { if v.Args[1].Op != OpConstPtr {
goto end2c6938f68a67e08dbd96edb1e693e549 goto end4323278ec7a053034fcf7033697d7b3b
} }
d := v.Args[1].AuxInt d := v.Args[1].AuxInt
if !(config.PtrSize == 4) { if !(config.PtrSize == 4) {
goto end2c6938f68a67e08dbd96edb1e693e549 goto end4323278ec7a053034fcf7033697d7b3b
} }
v.Op = OpConstBool v.Op = OpConstBool
v.AuxInt = 0 v.AuxInt = 0
v.Aux = nil v.Aux = nil
v.resetArgs() v.resetArgs()
v.Aux = inBounds32(c, d) v.AuxInt = b2i(inBounds32(c, d))
return true return true
} }
goto end2c6938f68a67e08dbd96edb1e693e549 goto end4323278ec7a053034fcf7033697d7b3b
end2c6938f68a67e08dbd96edb1e693e549: end4323278ec7a053034fcf7033697d7b3b:
; ;
// match: (IsInBounds (ConstPtr [c]) (ConstPtr [d])) // match: (IsInBounds (ConstPtr [c]) (ConstPtr [d]))
// cond: config.PtrSize == 8 // cond: config.PtrSize == 8
// result: (ConstBool {inBounds64(c,d)}) // result: (ConstBool [b2i(inBounds64(c,d))])
{ {
if v.Args[0].Op != OpConstPtr { if v.Args[0].Op != OpConstPtr {
goto end84d6ae817944985f572ecaac51999d6c goto endb550b8814df20b5eeda4f43cc94e902b
} }
c := v.Args[0].AuxInt c := v.Args[0].AuxInt
if v.Args[1].Op != OpConstPtr { if v.Args[1].Op != OpConstPtr {
goto end84d6ae817944985f572ecaac51999d6c goto endb550b8814df20b5eeda4f43cc94e902b
} }
d := v.Args[1].AuxInt d := v.Args[1].AuxInt
if !(config.PtrSize == 8) { if !(config.PtrSize == 8) {
goto end84d6ae817944985f572ecaac51999d6c goto endb550b8814df20b5eeda4f43cc94e902b
} }
v.Op = OpConstBool v.Op = OpConstBool
v.AuxInt = 0 v.AuxInt = 0
v.Aux = nil v.Aux = nil
v.resetArgs() v.resetArgs()
v.Aux = inBounds64(c, d) v.AuxInt = b2i(inBounds64(c, d))
return true return true
} }
goto end84d6ae817944985f572ecaac51999d6c goto endb550b8814df20b5eeda4f43cc94e902b
end84d6ae817944985f572ecaac51999d6c: endb550b8814df20b5eeda4f43cc94e902b:
; ;
case OpLoad: case OpLoad:
// match: (Load <t> ptr mem) // match: (Load <t> ptr mem)
...@@ -837,78 +837,78 @@ func rewriteValuegeneric(v *Value, config *Config) bool { ...@@ -837,78 +837,78 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
case OpNeq16: case OpNeq16:
// match: (Neq16 x x) // match: (Neq16 x x)
// cond: // cond:
// result: (ConstBool {false}) // result: (ConstBool [0])
{ {
x := v.Args[0] x := v.Args[0]
if v.Args[1] != x { if v.Args[1] != x {
goto end192755dd3c2be992e9d3deb53794a8d2 goto ende76a50b524aeb16c7aeccf5f5cc60c06
} }
v.Op = OpConstBool v.Op = OpConstBool
v.AuxInt = 0 v.AuxInt = 0
v.Aux = nil v.Aux = nil
v.resetArgs() v.resetArgs()
v.Aux = false v.AuxInt = 0
return true return true
} }
goto end192755dd3c2be992e9d3deb53794a8d2 goto ende76a50b524aeb16c7aeccf5f5cc60c06
end192755dd3c2be992e9d3deb53794a8d2: ende76a50b524aeb16c7aeccf5f5cc60c06:
; ;
case OpNeq32: case OpNeq32:
// match: (Neq32 x x) // match: (Neq32 x x)
// cond: // cond:
// result: (ConstBool {false}) // result: (ConstBool [0])
{ {
x := v.Args[0] x := v.Args[0]
if v.Args[1] != x { if v.Args[1] != x {
goto endeb23619fc85950a8df7b31126252c4dd goto end3713a608cffd29b40ff7c3b3f2585cbb
} }
v.Op = OpConstBool v.Op = OpConstBool
v.AuxInt = 0 v.AuxInt = 0
v.Aux = nil v.Aux = nil
v.resetArgs() v.resetArgs()
v.Aux = false v.AuxInt = 0
return true return true
} }
goto endeb23619fc85950a8df7b31126252c4dd goto end3713a608cffd29b40ff7c3b3f2585cbb
endeb23619fc85950a8df7b31126252c4dd: end3713a608cffd29b40ff7c3b3f2585cbb:
; ;
case OpNeq64: case OpNeq64:
// match: (Neq64 x x) // match: (Neq64 x x)
// cond: // cond:
// result: (ConstBool {false}) // result: (ConstBool [0])
{ {
x := v.Args[0] x := v.Args[0]
if v.Args[1] != x { if v.Args[1] != x {
goto endfc6eea780fb4056afb9e4287076da60c goto end3601ad382705ea12b79d2008c1e5725c
} }
v.Op = OpConstBool v.Op = OpConstBool
v.AuxInt = 0 v.AuxInt = 0
v.Aux = nil v.Aux = nil
v.resetArgs() v.resetArgs()
v.Aux = false v.AuxInt = 0
return true return true
} }
goto endfc6eea780fb4056afb9e4287076da60c goto end3601ad382705ea12b79d2008c1e5725c
endfc6eea780fb4056afb9e4287076da60c: end3601ad382705ea12b79d2008c1e5725c:
; ;
case OpNeq8: case OpNeq8:
// match: (Neq8 x x) // match: (Neq8 x x)
// cond: // cond:
// result: (ConstBool {false}) // result: (ConstBool [0])
{ {
x := v.Args[0] x := v.Args[0]
if v.Args[1] != x { if v.Args[1] != x {
goto endcccf700d93c6d57765b80f92f7b3fa81 goto end09a0deaf3c42627d0d2d3efa96e30745
} }
v.Op = OpConstBool v.Op = OpConstBool
v.AuxInt = 0 v.AuxInt = 0
v.Aux = nil v.Aux = nil
v.resetArgs() v.resetArgs()
v.Aux = false v.AuxInt = 0
return true return true
} }
goto endcccf700d93c6d57765b80f92f7b3fa81 goto end09a0deaf3c42627d0d2d3efa96e30745
endcccf700d93c6d57765b80f92f7b3fa81: end09a0deaf3c42627d0d2d3efa96e30745:
; ;
case OpNeqFat: case OpNeqFat:
// match: (NeqFat x y) // match: (NeqFat x y)
...@@ -1620,19 +1620,19 @@ func rewriteBlockgeneric(b *Block) bool { ...@@ -1620,19 +1620,19 @@ func rewriteBlockgeneric(b *Block) bool {
goto endebe19c1c3c3bec068cdb2dd29ef57f96 goto endebe19c1c3c3bec068cdb2dd29ef57f96
endebe19c1c3c3bec068cdb2dd29ef57f96: endebe19c1c3c3bec068cdb2dd29ef57f96:
; ;
// match: (If (ConstBool {c}) yes no) // match: (If (ConstBool [c]) yes no)
// cond: c.(bool) // cond: c == 1
// result: (First nil yes no) // result: (First nil yes no)
{ {
v := b.Control v := b.Control
if v.Op != OpConstBool { if v.Op != OpConstBool {
goto end7a20763049489cdb40bb1eaa57d113d8 goto endc58ecbb85af78c0d58bb232ca86b67a4
} }
c := v.Aux c := v.AuxInt
yes := b.Succs[0] yes := b.Succs[0]
no := b.Succs[1] no := b.Succs[1]
if !(c.(bool)) { if !(c == 1) {
goto end7a20763049489cdb40bb1eaa57d113d8 goto endc58ecbb85af78c0d58bb232ca86b67a4
} }
b.Kind = BlockFirst b.Kind = BlockFirst
b.Control = nil b.Control = nil
...@@ -1640,22 +1640,22 @@ func rewriteBlockgeneric(b *Block) bool { ...@@ -1640,22 +1640,22 @@ func rewriteBlockgeneric(b *Block) bool {
b.Succs[1] = no b.Succs[1] = no
return true return true
} }
goto end7a20763049489cdb40bb1eaa57d113d8 goto endc58ecbb85af78c0d58bb232ca86b67a4
end7a20763049489cdb40bb1eaa57d113d8: endc58ecbb85af78c0d58bb232ca86b67a4:
; ;
// match: (If (ConstBool {c}) yes no) // match: (If (ConstBool [c]) yes no)
// cond: !c.(bool) // cond: c == 0
// result: (First nil no yes) // result: (First nil no yes)
{ {
v := b.Control v := b.Control
if v.Op != OpConstBool { if v.Op != OpConstBool {
goto end3ecbf5b2cc1f0a08444d8ab1871a829c goto end4c3e297e275dd7e2e67f8ccd348c4bb5
} }
c := v.Aux c := v.AuxInt
yes := b.Succs[0] yes := b.Succs[0]
no := b.Succs[1] no := b.Succs[1]
if !(!c.(bool)) { if !(c == 0) {
goto end3ecbf5b2cc1f0a08444d8ab1871a829c goto end4c3e297e275dd7e2e67f8ccd348c4bb5
} }
b.Kind = BlockFirst b.Kind = BlockFirst
b.Control = nil b.Control = nil
...@@ -1664,8 +1664,8 @@ func rewriteBlockgeneric(b *Block) bool { ...@@ -1664,8 +1664,8 @@ func rewriteBlockgeneric(b *Block) bool {
b.Likely *= -1 b.Likely *= -1
return true return true
} }
goto end3ecbf5b2cc1f0a08444d8ab1871a829c goto end4c3e297e275dd7e2e67f8ccd348c4bb5
end3ecbf5b2cc1f0a08444d8ab1871a829c: end4c3e297e275dd7e2e67f8ccd348c4bb5:
} }
return false return false
} }
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