mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: cleanup SelectN rules by indexing into args
Change-Id: I7b8e8cd88c4d6d562aa25df91593d35d331ef63c Reviewed-on: https://go-review.googlesource.com/c/go/+/690595 Reviewed-by: Mark Freeman <mark@golang.org> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
94645d2413
commit
4569255f8c
2 changed files with 7 additions and 28 deletions
|
|
@ -2057,9 +2057,7 @@
|
|||
(Select1 (MakeTuple x y)) => y
|
||||
|
||||
// for rewriting results of some late-expanded rewrites (below)
|
||||
(SelectN [0] (MakeResult x ___)) => x
|
||||
(SelectN [1] (MakeResult x y ___)) => y
|
||||
(SelectN [2] (MakeResult x y z ___)) => z
|
||||
(SelectN [n] m:(MakeResult ___)) => m.Args[n]
|
||||
|
||||
// for late-expanded calls, recognize newobject and remove zeroing and nilchecks
|
||||
(Zero (SelectN [0] call:(StaticLECall _ _)) mem:(SelectN [1] call))
|
||||
|
|
|
|||
|
|
@ -29886,34 +29886,15 @@ func rewriteValuegeneric_OpSelectN(v *Value) bool {
|
|||
b := v.Block
|
||||
config := b.Func.Config
|
||||
typ := &b.Func.Config.Types
|
||||
// match: (SelectN [0] (MakeResult x ___))
|
||||
// result: x
|
||||
// match: (SelectN [n] m:(MakeResult ___))
|
||||
// result: m.Args[n]
|
||||
for {
|
||||
if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpMakeResult || len(v_0.Args) < 1 {
|
||||
n := auxIntToInt64(v.AuxInt)
|
||||
m := v_0
|
||||
if m.Op != OpMakeResult {
|
||||
break
|
||||
}
|
||||
x := v_0.Args[0]
|
||||
v.copyOf(x)
|
||||
return true
|
||||
}
|
||||
// match: (SelectN [1] (MakeResult x y ___))
|
||||
// result: y
|
||||
for {
|
||||
if auxIntToInt64(v.AuxInt) != 1 || v_0.Op != OpMakeResult || len(v_0.Args) < 2 {
|
||||
break
|
||||
}
|
||||
y := v_0.Args[1]
|
||||
v.copyOf(y)
|
||||
return true
|
||||
}
|
||||
// match: (SelectN [2] (MakeResult x y z ___))
|
||||
// result: z
|
||||
for {
|
||||
if auxIntToInt64(v.AuxInt) != 2 || v_0.Op != OpMakeResult || len(v_0.Args) < 3 {
|
||||
break
|
||||
}
|
||||
z := v_0.Args[2]
|
||||
v.copyOf(z)
|
||||
v.copyOf(m.Args[n])
|
||||
return true
|
||||
}
|
||||
// match: (SelectN [0] call:(StaticCall {sym} sptr (Const64 [c]) mem))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue