cmd/compile: reduce bounds checks in generated rewrite rules

CL 213703 converted generated rewrite rules for commutative ops
to use loops instead of duplicated code.

However, it loaded args using expressions like
v.Args[i] and v.Args[i^1], which the compiler could
not eliminate bounds for (including with all outstanding
prove CLs).

Also, given a series of separate rewrite rules for the same op,
we generated bounds checks for every rewrite rule, even though
we were repeatedly loading the same set of args.

This change reduces both sets of bounds checks.

Instead of loading v.Args[i] and v.Args[i^1] for commutative loops,
we now preload v.Args[0] and v.Args[1] into local variables,
and then swap them (as needed) in the commutative loop post statement.

And we now load all top level v.Args into local variables
at the beginning of every rewrite rule function.

The second optimization is the more significant,
but the first helps a little, and they play together
nicely from the perspective of generating the code.

This does increase register pressure, but the reduced bounds
checks more than compensate.

Note that the vast majority of rewrite rules evaluated
are not applied, so the prologue is the most important
part of the rewrite rules.

There is one subtle aspect to the new generated code.
Because the top level v.Args are shared across rewrite rules,
and rule evaluation can swap v_0 and v_1, v_0 and v_1
can end up being swapped from one rule to the next.
That is OK, because any time a rule does not get applied,
they will have been swapped exactly twice.

Passes toolstash-check -all.

name        old time/op       new time/op       delta
Template          213ms ± 2%        211ms ± 2%  -0.85%  (p=0.000 n=92+96)
Unicode          83.5ms ± 2%       83.2ms ± 2%  -0.41%  (p=0.004 n=95+90)
GoTypes           737ms ± 2%        733ms ± 2%  -0.51%  (p=0.000 n=91+94)
Compiler          3.45s ± 2%        3.43s ± 2%  -0.44%  (p=0.000 n=99+100)
SSA               8.54s ± 1%        8.32s ± 2%  -2.56%  (p=0.000 n=96+99)
Flate             136ms ± 2%        135ms ± 1%  -0.47%  (p=0.000 n=96+96)
GoParser          169ms ± 1%        168ms ± 1%  -0.33%  (p=0.000 n=96+93)
Reflect           456ms ± 3%        455ms ± 3%    ~     (p=0.261 n=95+94)
Tar               186ms ± 2%        185ms ± 2%  -0.48%  (p=0.000 n=94+95)
XML               251ms ± 1%        250ms ± 1%  -0.51%  (p=0.000 n=91+94)
[Geo mean]        424ms             421ms       -0.68%

name        old user-time/op  new user-time/op  delta
Template          275ms ± 1%        274ms ± 2%  -0.55%  (p=0.000 n=95+98)
Unicode           118ms ± 4%        118ms ± 4%    ~     (p=0.642 n=98+90)
GoTypes           983ms ± 1%        980ms ± 1%  -0.30%  (p=0.000 n=93+93)
Compiler          4.56s ± 6%        4.52s ± 6%  -0.72%  (p=0.003 n=100+100)
SSA               11.4s ± 1%        11.1s ± 1%  -2.50%  (p=0.000 n=96+97)
Flate             168ms ± 1%        167ms ± 1%  -0.49%  (p=0.000 n=92+92)
GoParser          204ms ± 1%        204ms ± 2%  -0.27%  (p=0.003 n=99+96)
Reflect           599ms ± 2%        598ms ± 2%    ~     (p=0.116 n=95+92)
Tar               227ms ± 2%        225ms ± 2%  -0.57%  (p=0.000 n=95+98)
XML               313ms ± 2%        312ms ± 1%  -0.37%  (p=0.000 n=89+95)
[Geo mean]        547ms             544ms       -0.61%

file    before    after     Δ       %
compile 21113112  21109016  -4096   -0.019%
total   131704940 131700844 -4096   -0.003%

Change-Id: Id6c39e0367e597c0c75b8a4b1eb14cc3cbd11956
Reviewed-on: https://go-review.googlesource.com/c/go/+/216218
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2020-01-20 20:09:41 -08:00
parent a37bbcecca
commit a3f234c706
16 changed files with 24009 additions and 24209 deletions

View File

@ -172,7 +172,7 @@ func genRulesSuffix(arch arch, suff string) {
genFile := &File{arch: arch, suffix: suff}
const chunkSize = 10
// Main rewrite routine is a switch on v.Op.
fn := &Func{kind: "Value"}
fn := &Func{kind: "Value", arglen: -1}
sw := &Switch{expr: exprf("v.Op")}
for _, op := range ops {
@ -218,6 +218,7 @@ func genRulesSuffix(arch arch, suff string) {
fn := &Func{
kind: "Value",
suffix: fmt.Sprintf("_%s_%d", op, chunk),
arglen: opByName(arch, op).argLength,
}
fn.add(declf("b", "v.Block"))
fn.add(declf("config", "b.Func.Config"))
@ -229,7 +230,7 @@ func genRulesSuffix(arch arch, suff string) {
}
rr = &RuleRewrite{loc: rule.loc}
rr.match, rr.cond, rr.result = rule.parse()
pos, _ := genMatch(rr, arch, rr.match)
pos, _ := genMatch(rr, arch, rr.match, fn.arglen >= 0)
if pos == "" {
pos = "v.Pos"
}
@ -593,6 +594,11 @@ func fprint(w io.Writer, n Node) {
f := f.(*Func)
fmt.Fprintf(w, "func rewrite%s%s%s%s(", f.kind, n.arch.name, n.suffix, f.suffix)
fmt.Fprintf(w, "%c *%s) bool {\n", strings.ToLower(f.kind)[0], f.kind)
if f.kind == "Value" && f.arglen > 0 {
for i := f.arglen - 1; i >= 0; i-- {
fmt.Fprintf(w, "v_%d := v.Args[%d]\n", i, i)
}
}
for _, n := range f.list {
fprint(w, n)
@ -677,7 +683,7 @@ func fprint(w io.Writer, n Node) {
fmt.Fprintln(w)
}
case StartCommuteLoop:
fmt.Fprintf(w, "for _i%d := 0; _i%d <= 1; _i%d++ {\n", n.depth, n.depth, n.depth)
fmt.Fprintf(w, "for _i%[1]d := 0; _i%[1]d <= 1; _i%[1]d, %[2]s_0, %[2]s_1 = _i%[1]d + 1, %[2]s_1, %[2]s_0 {\n", n.depth, n.v)
default:
log.Fatalf("cannot print %T", n)
}
@ -751,6 +757,7 @@ type (
bodyBase
kind string // "Value" or "Block"
suffix string
arglen int32 // if kind == "Value", number of args for this op
}
Switch struct {
bodyBase // []*Case
@ -779,6 +786,7 @@ type (
}
StartCommuteLoop struct {
depth int
v string
}
)
@ -835,7 +843,7 @@ func genBlockRewrite(rule Rule, arch arch, data blockData) *RuleRewrite {
cname := fmt.Sprintf("b.Controls[%v]", i)
vname := fmt.Sprintf("v_%v", i)
rr.add(declf(vname, cname))
p, op := genMatch0(rr, arch, arg, vname, nil) // TODO: pass non-nil cnt?
p, op := genMatch0(rr, arch, arg, vname, nil, false) // TODO: pass non-nil cnt?
if op != "" {
check := fmt.Sprintf("%s.Op == %s", cname, op)
if rr.check == "" {
@ -948,12 +956,12 @@ func genBlockRewrite(rule Rule, arch arch, data blockData) *RuleRewrite {
// genMatch returns the variable whose source position should be used for the
// result (or "" if no opinion), and a boolean that reports whether the match can fail.
func genMatch(rr *RuleRewrite, arch arch, match string) (pos, checkOp string) {
func genMatch(rr *RuleRewrite, arch arch, match string, pregenTop bool) (pos, checkOp string) {
cnt := varCount(rr.match, rr.cond)
return genMatch0(rr, arch, match, "v", cnt)
return genMatch0(rr, arch, match, "v", cnt, pregenTop)
}
func genMatch0(rr *RuleRewrite, arch arch, match, v string, cnt map[string]int) (pos, checkOp string) {
func genMatch0(rr *RuleRewrite, arch arch, match, v string, cnt map[string]int, pregenTop bool) (pos, checkOp string) {
if match[0] != '(' || match[len(match)-1] != ')' {
log.Fatalf("non-compound expr in genMatch0: %q", match)
}
@ -1002,7 +1010,7 @@ func genMatch0(rr *RuleRewrite, arch arch, match, v string, cnt map[string]int)
}
// Access last argument first to minimize bounds checks.
if n := len(args); n > 1 {
if n := len(args); n > 1 && !pregenTop {
a := args[n-1]
if a != "_" && !rr.declared(a) && token.IsIdentifier(a) && !(commutative && len(args) == 2) {
rr.add(declf(a, "%s.Args[%d]", v, n-1))
@ -1013,25 +1021,28 @@ func genMatch0(rr *RuleRewrite, arch arch, match, v string, cnt map[string]int)
rr.add(stmtf("_ = %s.Args[%d]", v, n-1))
}
}
if commutative && !pregenTop {
for i := 0; i <= 1; i++ {
vname := fmt.Sprintf("%s_%d", v, i)
rr.add(declf(vname, "%s.Args[%d]", v, i))
}
}
var commuteDepth int
if commutative {
commuteDepth = rr.commuteDepth
rr.add(StartCommuteLoop{commuteDepth})
rr.add(StartCommuteLoop{commuteDepth, v})
rr.commuteDepth++
}
for i, arg := range args {
argidx := strconv.Itoa(i)
if commutative {
switch i {
case 0:
argidx = fmt.Sprintf("_i%d", commuteDepth)
case 1:
argidx = fmt.Sprintf("1^_i%d", commuteDepth)
}
}
if arg == "_" {
continue
}
var rhs string
if (commutative && i < 2) || pregenTop {
rhs = fmt.Sprintf("%s_%d", v, i)
} else {
rhs = fmt.Sprintf("%s.Args[%d]", v, i)
}
if !strings.Contains(arg, "(") {
// leaf variable
if rr.declared(arg) {
@ -1039,9 +1050,11 @@ func genMatch0(rr *RuleRewrite, arch arch, match, v string, cnt map[string]int)
// the old definition and the new definition match.
// For example, (add x x). Equality is just pointer equality
// on Values (so cse is important to do before lowering).
rr.add(breakf("%s != %s.Args[%s]", arg, v, argidx))
rr.add(breakf("%s != %s", arg, rhs))
} else {
rr.add(declf(arg, "%s.Args[%s]", v, argidx))
if arg != rhs {
rr.add(declf(arg, "%s", rhs))
}
}
continue
}
@ -1058,10 +1071,12 @@ func genMatch0(rr *RuleRewrite, arch arch, match, v string, cnt map[string]int)
log.Fatalf("don't name args 'b', it is ambiguous with blocks")
}
rr.add(declf(argname, "%s.Args[%s]", v, argidx))
if argname != rhs {
rr.add(declf(argname, "%s", rhs))
}
bexpr := exprf("%s.Op != addLater", argname)
rr.add(&CondBreak{expr: bexpr})
argPos, argCheckOp := genMatch0(rr, arch, arg, argname, cnt)
argPos, argCheckOp := genMatch0(rr, arch, arg, argname, cnt, false)
bexpr.(*ast.BinaryExpr).Y.(*ast.Ident).Name = argCheckOp
if argPos != "" {
@ -1546,3 +1561,22 @@ func isEllipsisValue(s string) bool {
}
return true
}
func opByName(arch arch, name string) opData {
name = name[2:]
for _, x := range genericOps {
if name == x.name {
return x
}
}
if arch.name != "generic" {
name = name[len(arch.name):]
for _, x := range arch.ops {
if name == x.name {
return x
}
}
}
log.Fatalf("failed to find op named %s in arch %s", name, arch.name)
panic("unreachable")
}

File diff suppressed because it is too large Load Diff

View File

@ -21,6 +21,8 @@ func rewriteValue386splitload(v *Value) bool {
return false
}
func rewriteValue386splitload_Op386CMPBconstload_0(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (CMPBconstload {sym} [vo] ptr mem)
@ -28,8 +30,8 @@ func rewriteValue386splitload_Op386CMPBconstload_0(v *Value) bool {
for {
vo := v.AuxInt
sym := v.Aux
mem := v.Args[1]
ptr := v.Args[0]
ptr := v_0
mem := v_1
v.reset(Op386CMPBconst)
v.AuxInt = valOnly(vo)
v0 := b.NewValue0(v.Pos, Op386MOVBload, typ.UInt8)
@ -42,6 +44,9 @@ func rewriteValue386splitload_Op386CMPBconstload_0(v *Value) bool {
}
}
func rewriteValue386splitload_Op386CMPBload_0(v *Value) bool {
v_2 := v.Args[2]
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (CMPBload {sym} [off] ptr x mem)
@ -49,9 +54,9 @@ func rewriteValue386splitload_Op386CMPBload_0(v *Value) bool {
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
ptr := v.Args[0]
x := v.Args[1]
ptr := v_0
x := v_1
mem := v_2
v.reset(Op386CMPB)
v0 := b.NewValue0(v.Pos, Op386MOVBload, typ.UInt8)
v0.AuxInt = off
@ -64,6 +69,8 @@ func rewriteValue386splitload_Op386CMPBload_0(v *Value) bool {
}
}
func rewriteValue386splitload_Op386CMPLconstload_0(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (CMPLconstload {sym} [vo] ptr mem)
@ -71,8 +78,8 @@ func rewriteValue386splitload_Op386CMPLconstload_0(v *Value) bool {
for {
vo := v.AuxInt
sym := v.Aux
mem := v.Args[1]
ptr := v.Args[0]
ptr := v_0
mem := v_1
v.reset(Op386CMPLconst)
v.AuxInt = valOnly(vo)
v0 := b.NewValue0(v.Pos, Op386MOVLload, typ.UInt32)
@ -85,6 +92,9 @@ func rewriteValue386splitload_Op386CMPLconstload_0(v *Value) bool {
}
}
func rewriteValue386splitload_Op386CMPLload_0(v *Value) bool {
v_2 := v.Args[2]
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (CMPLload {sym} [off] ptr x mem)
@ -92,9 +102,9 @@ func rewriteValue386splitload_Op386CMPLload_0(v *Value) bool {
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
ptr := v.Args[0]
x := v.Args[1]
ptr := v_0
x := v_1
mem := v_2
v.reset(Op386CMPL)
v0 := b.NewValue0(v.Pos, Op386MOVLload, typ.UInt32)
v0.AuxInt = off
@ -107,6 +117,8 @@ func rewriteValue386splitload_Op386CMPLload_0(v *Value) bool {
}
}
func rewriteValue386splitload_Op386CMPWconstload_0(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (CMPWconstload {sym} [vo] ptr mem)
@ -114,8 +126,8 @@ func rewriteValue386splitload_Op386CMPWconstload_0(v *Value) bool {
for {
vo := v.AuxInt
sym := v.Aux
mem := v.Args[1]
ptr := v.Args[0]
ptr := v_0
mem := v_1
v.reset(Op386CMPWconst)
v.AuxInt = valOnly(vo)
v0 := b.NewValue0(v.Pos, Op386MOVWload, typ.UInt16)
@ -128,6 +140,9 @@ func rewriteValue386splitload_Op386CMPWconstload_0(v *Value) bool {
}
}
func rewriteValue386splitload_Op386CMPWload_0(v *Value) bool {
v_2 := v.Args[2]
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (CMPWload {sym} [off] ptr x mem)
@ -135,9 +150,9 @@ func rewriteValue386splitload_Op386CMPWload_0(v *Value) bool {
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
ptr := v.Args[0]
x := v.Args[1]
ptr := v_0
x := v_1
mem := v_2
v.reset(Op386CMPW)
v0 := b.NewValue0(v.Pos, Op386MOVWload, typ.UInt16)
v0.AuxInt = off

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,8 @@ func rewriteValueAMD64splitload(v *Value) bool {
return false
}
func rewriteValueAMD64splitload_OpAMD64CMPBconstload_0(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (CMPBconstload {sym} [vo] ptr mem)
@ -32,8 +34,8 @@ func rewriteValueAMD64splitload_OpAMD64CMPBconstload_0(v *Value) bool {
for {
vo := v.AuxInt
sym := v.Aux
mem := v.Args[1]
ptr := v.Args[0]
ptr := v_0
mem := v_1
v.reset(OpAMD64CMPBconst)
v.AuxInt = valOnly(vo)
v0 := b.NewValue0(v.Pos, OpAMD64MOVBload, typ.UInt8)
@ -46,6 +48,9 @@ func rewriteValueAMD64splitload_OpAMD64CMPBconstload_0(v *Value) bool {
}
}
func rewriteValueAMD64splitload_OpAMD64CMPBload_0(v *Value) bool {
v_2 := v.Args[2]
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (CMPBload {sym} [off] ptr x mem)
@ -53,9 +58,9 @@ func rewriteValueAMD64splitload_OpAMD64CMPBload_0(v *Value) bool {
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
ptr := v.Args[0]
x := v.Args[1]
ptr := v_0
x := v_1
mem := v_2
v.reset(OpAMD64CMPB)
v0 := b.NewValue0(v.Pos, OpAMD64MOVBload, typ.UInt8)
v0.AuxInt = off
@ -68,6 +73,8 @@ func rewriteValueAMD64splitload_OpAMD64CMPBload_0(v *Value) bool {
}
}
func rewriteValueAMD64splitload_OpAMD64CMPLconstload_0(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (CMPLconstload {sym} [vo] ptr mem)
@ -75,8 +82,8 @@ func rewriteValueAMD64splitload_OpAMD64CMPLconstload_0(v *Value) bool {
for {
vo := v.AuxInt
sym := v.Aux
mem := v.Args[1]
ptr := v.Args[0]
ptr := v_0
mem := v_1
v.reset(OpAMD64CMPLconst)
v.AuxInt = valOnly(vo)
v0 := b.NewValue0(v.Pos, OpAMD64MOVLload, typ.UInt32)
@ -89,6 +96,9 @@ func rewriteValueAMD64splitload_OpAMD64CMPLconstload_0(v *Value) bool {
}
}
func rewriteValueAMD64splitload_OpAMD64CMPLload_0(v *Value) bool {
v_2 := v.Args[2]
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (CMPLload {sym} [off] ptr x mem)
@ -96,9 +106,9 @@ func rewriteValueAMD64splitload_OpAMD64CMPLload_0(v *Value) bool {
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
ptr := v.Args[0]
x := v.Args[1]
ptr := v_0
x := v_1
mem := v_2
v.reset(OpAMD64CMPL)
v0 := b.NewValue0(v.Pos, OpAMD64MOVLload, typ.UInt32)
v0.AuxInt = off
@ -111,6 +121,8 @@ func rewriteValueAMD64splitload_OpAMD64CMPLload_0(v *Value) bool {
}
}
func rewriteValueAMD64splitload_OpAMD64CMPQconstload_0(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (CMPQconstload {sym} [vo] ptr mem)
@ -118,8 +130,8 @@ func rewriteValueAMD64splitload_OpAMD64CMPQconstload_0(v *Value) bool {
for {
vo := v.AuxInt
sym := v.Aux
mem := v.Args[1]
ptr := v.Args[0]
ptr := v_0
mem := v_1
v.reset(OpAMD64CMPQconst)
v.AuxInt = valOnly(vo)
v0 := b.NewValue0(v.Pos, OpAMD64MOVQload, typ.UInt64)
@ -132,6 +144,9 @@ func rewriteValueAMD64splitload_OpAMD64CMPQconstload_0(v *Value) bool {
}
}
func rewriteValueAMD64splitload_OpAMD64CMPQload_0(v *Value) bool {
v_2 := v.Args[2]
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (CMPQload {sym} [off] ptr x mem)
@ -139,9 +154,9 @@ func rewriteValueAMD64splitload_OpAMD64CMPQload_0(v *Value) bool {
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
ptr := v.Args[0]
x := v.Args[1]
ptr := v_0
x := v_1
mem := v_2
v.reset(OpAMD64CMPQ)
v0 := b.NewValue0(v.Pos, OpAMD64MOVQload, typ.UInt64)
v0.AuxInt = off
@ -154,6 +169,8 @@ func rewriteValueAMD64splitload_OpAMD64CMPQload_0(v *Value) bool {
}
}
func rewriteValueAMD64splitload_OpAMD64CMPWconstload_0(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (CMPWconstload {sym} [vo] ptr mem)
@ -161,8 +178,8 @@ func rewriteValueAMD64splitload_OpAMD64CMPWconstload_0(v *Value) bool {
for {
vo := v.AuxInt
sym := v.Aux
mem := v.Args[1]
ptr := v.Args[0]
ptr := v_0
mem := v_1
v.reset(OpAMD64CMPWconst)
v.AuxInt = valOnly(vo)
v0 := b.NewValue0(v.Pos, OpAMD64MOVWload, typ.UInt16)
@ -175,6 +192,9 @@ func rewriteValueAMD64splitload_OpAMD64CMPWconstload_0(v *Value) bool {
}
}
func rewriteValueAMD64splitload_OpAMD64CMPWload_0(v *Value) bool {
v_2 := v.Args[2]
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (CMPWload {sym} [off] ptr x mem)
@ -182,9 +202,9 @@ func rewriteValueAMD64splitload_OpAMD64CMPWload_0(v *Value) bool {
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
ptr := v.Args[0]
x := v.Args[1]
ptr := v_0
x := v_1
mem := v_2
v.reset(OpAMD64CMPW)
v0 := b.NewValue0(v.Pos, OpAMD64MOVWload, typ.UInt16)
v0.AuxInt = off

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -33,10 +33,10 @@ func rewriteValuedec(v *Value) bool {
return false
}
func rewriteValuedec_OpComplexImag_0(v *Value) bool {
v_0 := v.Args[0]
// match: (ComplexImag (ComplexMake _ imag ))
// result: imag
for {
v_0 := v.Args[0]
if v_0.Op != OpComplexMake {
break
}
@ -49,10 +49,10 @@ func rewriteValuedec_OpComplexImag_0(v *Value) bool {
return false
}
func rewriteValuedec_OpComplexReal_0(v *Value) bool {
v_0 := v.Args[0]
// match: (ComplexReal (ComplexMake real _ ))
// result: real
for {
v_0 := v.Args[0]
if v_0.Op != OpComplexMake {
break
}
@ -66,10 +66,10 @@ func rewriteValuedec_OpComplexReal_0(v *Value) bool {
return false
}
func rewriteValuedec_OpIData_0(v *Value) bool {
v_0 := v.Args[0]
// match: (IData (IMake _ data))
// result: data
for {
v_0 := v.Args[0]
if v_0.Op != OpIMake {
break
}
@ -82,10 +82,10 @@ func rewriteValuedec_OpIData_0(v *Value) bool {
return false
}
func rewriteValuedec_OpITab_0(v *Value) bool {
v_0 := v.Args[0]
// match: (ITab (IMake itab _))
// result: itab
for {
v_0 := v.Args[0]
if v_0.Op != OpIMake {
break
}
@ -99,6 +99,8 @@ func rewriteValuedec_OpITab_0(v *Value) bool {
return false
}
func rewriteValuedec_OpLoad_0(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
config := b.Func.Config
typ := &b.Func.Config.Types
@ -107,8 +109,8 @@ func rewriteValuedec_OpLoad_0(v *Value) bool {
// result: (ComplexMake (Load <typ.Float32> ptr mem) (Load <typ.Float32> (OffPtr <typ.Float32Ptr> [4] ptr) mem) )
for {
t := v.Type
mem := v.Args[1]
ptr := v.Args[0]
ptr := v_0
mem := v_1
if !(t.IsComplex() && t.Size() == 8) {
break
}
@ -131,8 +133,8 @@ func rewriteValuedec_OpLoad_0(v *Value) bool {
// result: (ComplexMake (Load <typ.Float64> ptr mem) (Load <typ.Float64> (OffPtr <typ.Float64Ptr> [8] ptr) mem) )
for {
t := v.Type
mem := v.Args[1]
ptr := v.Args[0]
ptr := v_0
mem := v_1
if !(t.IsComplex() && t.Size() == 16) {
break
}
@ -155,8 +157,8 @@ func rewriteValuedec_OpLoad_0(v *Value) bool {
// result: (StringMake (Load <typ.BytePtr> ptr mem) (Load <typ.Int> (OffPtr <typ.IntPtr> [config.PtrSize] ptr) mem))
for {
t := v.Type
mem := v.Args[1]
ptr := v.Args[0]
ptr := v_0
mem := v_1
if !(t.IsString()) {
break
}
@ -179,8 +181,8 @@ func rewriteValuedec_OpLoad_0(v *Value) bool {
// result: (SliceMake (Load <t.Elem().PtrTo()> ptr mem) (Load <typ.Int> (OffPtr <typ.IntPtr> [config.PtrSize] ptr) mem) (Load <typ.Int> (OffPtr <typ.IntPtr> [2*config.PtrSize] ptr) mem))
for {
t := v.Type
mem := v.Args[1]
ptr := v.Args[0]
ptr := v_0
mem := v_1
if !(t.IsSlice()) {
break
}
@ -210,8 +212,8 @@ func rewriteValuedec_OpLoad_0(v *Value) bool {
// result: (IMake (Load <typ.Uintptr> ptr mem) (Load <typ.BytePtr> (OffPtr <typ.BytePtrPtr> [config.PtrSize] ptr) mem))
for {
t := v.Type
mem := v.Args[1]
ptr := v.Args[0]
ptr := v_0
mem := v_1
if !(t.IsInterface()) {
break
}
@ -232,10 +234,10 @@ func rewriteValuedec_OpLoad_0(v *Value) bool {
return false
}
func rewriteValuedec_OpSliceCap_0(v *Value) bool {
v_0 := v.Args[0]
// match: (SliceCap (SliceMake _ _ cap))
// result: cap
for {
v_0 := v.Args[0]
if v_0.Op != OpSliceMake {
break
}
@ -248,10 +250,10 @@ func rewriteValuedec_OpSliceCap_0(v *Value) bool {
return false
}
func rewriteValuedec_OpSliceLen_0(v *Value) bool {
v_0 := v.Args[0]
// match: (SliceLen (SliceMake _ len _))
// result: len
for {
v_0 := v.Args[0]
if v_0.Op != OpSliceMake {
break
}
@ -265,10 +267,10 @@ func rewriteValuedec_OpSliceLen_0(v *Value) bool {
return false
}
func rewriteValuedec_OpSlicePtr_0(v *Value) bool {
v_0 := v.Args[0]
// match: (SlicePtr (SliceMake ptr _ _ ))
// result: ptr
for {
v_0 := v.Args[0]
if v_0.Op != OpSliceMake {
break
}
@ -282,6 +284,9 @@ func rewriteValuedec_OpSlicePtr_0(v *Value) bool {
return false
}
func rewriteValuedec_OpStore_0(v *Value) bool {
v_2 := v.Args[2]
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
config := b.Func.Config
typ := &b.Func.Config.Types
@ -290,14 +295,13 @@ func rewriteValuedec_OpStore_0(v *Value) bool {
// result: (Store {typ.Float32} (OffPtr <typ.Float32Ptr> [4] dst) imag (Store {typ.Float32} dst real mem))
for {
t := v.Aux
mem := v.Args[2]
dst := v.Args[0]
v_1 := v.Args[1]
dst := v_0
if v_1.Op != OpComplexMake {
break
}
imag := v_1.Args[1]
real := v_1.Args[0]
mem := v_2
if !(t.(*types.Type).Size() == 8) {
break
}
@ -321,14 +325,13 @@ func rewriteValuedec_OpStore_0(v *Value) bool {
// result: (Store {typ.Float64} (OffPtr <typ.Float64Ptr> [8] dst) imag (Store {typ.Float64} dst real mem))
for {
t := v.Aux
mem := v.Args[2]
dst := v.Args[0]
v_1 := v.Args[1]
dst := v_0
if v_1.Op != OpComplexMake {
break
}
imag := v_1.Args[1]
real := v_1.Args[0]
mem := v_2
if !(t.(*types.Type).Size() == 16) {
break
}
@ -350,14 +353,13 @@ func rewriteValuedec_OpStore_0(v *Value) bool {
// match: (Store dst (StringMake ptr len) mem)
// result: (Store {typ.Int} (OffPtr <typ.IntPtr> [config.PtrSize] dst) len (Store {typ.BytePtr} dst ptr mem))
for {
mem := v.Args[2]
dst := v.Args[0]
v_1 := v.Args[1]
dst := v_0
if v_1.Op != OpStringMake {
break
}
len := v_1.Args[1]
ptr := v_1.Args[0]
mem := v_2
v.reset(OpStore)
v.Aux = typ.Int
v0 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
@ -376,15 +378,14 @@ func rewriteValuedec_OpStore_0(v *Value) bool {
// match: (Store dst (SliceMake ptr len cap) mem)
// result: (Store {typ.Int} (OffPtr <typ.IntPtr> [2*config.PtrSize] dst) cap (Store {typ.Int} (OffPtr <typ.IntPtr> [config.PtrSize] dst) len (Store {typ.BytePtr} dst ptr mem)))
for {
mem := v.Args[2]
dst := v.Args[0]
v_1 := v.Args[1]
dst := v_0
if v_1.Op != OpSliceMake {
break
}
cap := v_1.Args[2]
ptr := v_1.Args[0]
len := v_1.Args[1]
mem := v_2
v.reset(OpStore)
v.Aux = typ.Int
v0 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
@ -411,14 +412,13 @@ func rewriteValuedec_OpStore_0(v *Value) bool {
// match: (Store dst (IMake itab data) mem)
// result: (Store {typ.BytePtr} (OffPtr <typ.BytePtrPtr> [config.PtrSize] dst) data (Store {typ.Uintptr} dst itab mem))
for {
mem := v.Args[2]
dst := v.Args[0]
v_1 := v.Args[1]
dst := v_0
if v_1.Op != OpIMake {
break
}
data := v_1.Args[1]
itab := v_1.Args[0]
mem := v_2
v.reset(OpStore)
v.Aux = typ.BytePtr
v0 := b.NewValue0(v.Pos, OpOffPtr, typ.BytePtrPtr)
@ -437,10 +437,10 @@ func rewriteValuedec_OpStore_0(v *Value) bool {
return false
}
func rewriteValuedec_OpStringLen_0(v *Value) bool {
v_0 := v.Args[0]
// match: (StringLen (StringMake _ len))
// result: len
for {
v_0 := v.Args[0]
if v_0.Op != OpStringMake {
break
}
@ -453,10 +453,10 @@ func rewriteValuedec_OpStringLen_0(v *Value) bool {
return false
}
func rewriteValuedec_OpStringPtr_0(v *Value) bool {
v_0 := v.Args[0]
// match: (StringPtr (StringMake ptr _))
// result: ptr
for {
v_0 := v.Args[0]
if v_0.Op != OpStringMake {
break
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff