1
0
mirror of https://github.com/golang/go synced 2024-11-23 07:00:05 -07:00

cmd/compile: generate commutative rules when a condition is present

The commutative rule generator has an optimization
where given (Add x y) with no other uses of x and y in the matching rule,
it doesn't generate the commutative match (Add y x).

However, if there is also a condition referring to x or y,
such as (Add x y) && isFoo(x), then we should generate the commutative rule.
This change parses the condition, extracts all idents, and takes them
into consideration.

This doesn't yield any new optimizations now.
However, it is the right thing to do;
otherwise we'll have to track it down and fix it again later.

It is also expensive now, in terms of additional generated code.
However, it will be much, much less expensive soon,
once our generated code for commutative ops gets smaller.

Change-Id: I52c2016c884bbc7789bf8dfe9b9c56061bc028ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/213702
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2020-01-06 23:45:57 -08:00
parent 6817210edf
commit 73269b8e75
6 changed files with 3639 additions and 83 deletions

View File

@ -1339,7 +1339,7 @@ func expandOr(r string) []string {
// Potentially exponential, be careful.
func commute(r string, arch arch) []string {
match, cond, result := Rule{rule: r}.parse()
a := commute1(match, varCount(match), arch)
a := commute1(match, varCount(match, cond), arch)
for i, m := range a {
if cond != "" {
m += " && " + cond
@ -1428,10 +1428,22 @@ func commute1(m string, cnt map[string]int, arch arch) []string {
}
// varCount returns a map which counts the number of occurrences of
// Value variables in m.
func varCount(m string) map[string]int {
// Value variables in the s-expression "match" and the Go expression "cond".
func varCount(match, cond string) map[string]int {
cnt := map[string]int{}
varCount1(m, cnt)
varCount1(match, cnt)
if cond != "" {
expr, err := parser.ParseExpr(cond)
if err != nil {
log.Fatalf("failed to parse cond %q: %v", cond, err)
}
ast.Inspect(expr, func(n ast.Node) bool {
if id, ok := n.(*ast.Ident); ok {
cnt[id.Name]++
}
return true
})
}
return cnt
}

View File

@ -165,7 +165,7 @@ func rewriteValue386(v *Value) bool {
case Op386MOVWloadidx2:
return rewriteValue386_Op386MOVWloadidx2_0(v)
case Op386MOVWstore:
return rewriteValue386_Op386MOVWstore_0(v)
return rewriteValue386_Op386MOVWstore_0(v) || rewriteValue386_Op386MOVWstore_10(v)
case Op386MOVWstoreconst:
return rewriteValue386_Op386MOVWstoreconst_0(v)
case Op386MOVWstoreconstidx1:
@ -4015,6 +4015,28 @@ func rewriteValue386_Op386LEAL_0(v *Value) bool {
v.AddArg(y)
return true
}
// match: (LEAL [c] {s} (ADDL y x))
// cond: x.Op != OpSB && y.Op != OpSB
// result: (LEAL1 [c] {s} x y)
for {
c := v.AuxInt
s := v.Aux
v_0 := v.Args[0]
if v_0.Op != Op386ADDL {
break
}
x := v_0.Args[1]
y := v_0.Args[0]
if !(x.Op != OpSB && y.Op != OpSB) {
break
}
v.reset(Op386LEAL1)
v.AuxInt = c
v.Aux = s
v.AddArg(x)
v.AddArg(y)
return true
}
// match: (LEAL [off1] {sym1} (LEAL [off2] {sym2} x))
// cond: is32Bit(off1+off2) && canMergeSym(sym1, sym2)
// result: (LEAL [off1+off2] {mergeSym(sym1,sym2)} x)
@ -4918,6 +4940,30 @@ func rewriteValue386_Op386MOVBload_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVBload [off] {sym} (ADDL idx ptr) mem)
// cond: ptr.Op != OpSB
// result: (MOVBloadidx1 [off] {sym} ptr idx mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[1]
v_0 := v.Args[0]
if v_0.Op != Op386ADDL {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
if !(ptr.Op != OpSB) {
break
}
v.reset(Op386MOVBloadidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(mem)
return true
}
// match: (MOVBload [off] {sym} (SB) _)
// cond: symIsRO(sym)
// result: (MOVLconst [int64(read8(sym, off))])
@ -5193,6 +5239,32 @@ func rewriteValue386_Op386MOVBstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVBstore [off] {sym} (ADDL idx ptr) val mem)
// cond: ptr.Op != OpSB
// result: (MOVBstoreidx1 [off] {sym} ptr idx val mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
v_0 := v.Args[0]
if v_0.Op != Op386ADDL {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
val := v.Args[1]
if !(ptr.Op != OpSB) {
break
}
v.reset(Op386MOVBstoreidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(val)
v.AddArg(mem)
return true
}
// match: (MOVBstore [i] {s} p (SHRWconst [8] w) x:(MOVBstore [i-1] {s} p w mem))
// cond: x.Uses == 1 && clobber(x)
// result: (MOVWstore [i-1] {s} p w mem)
@ -5251,6 +5323,9 @@ func rewriteValue386_Op386MOVBstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValue386_Op386MOVBstore_10(v *Value) bool {
// match: (MOVBstore [i] {s} p w x:(MOVBstore {s} [i+1] p (SHRWconst [8] w) mem))
// cond: x.Uses == 1 && clobber(x)
// result: (MOVWstore [i] {s} p w mem)
@ -5280,9 +5355,6 @@ func rewriteValue386_Op386MOVBstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValue386_Op386MOVBstore_10(v *Value) bool {
// match: (MOVBstore [i] {s} p w x:(MOVBstore {s} [i+1] p (SHRLconst [8] w) mem))
// cond: x.Uses == 1 && clobber(x)
// result: (MOVWstore [i] {s} p w mem)
@ -6466,6 +6538,30 @@ func rewriteValue386_Op386MOVLload_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVLload [off] {sym} (ADDL idx ptr) mem)
// cond: ptr.Op != OpSB
// result: (MOVLloadidx1 [off] {sym} ptr idx mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[1]
v_0 := v.Args[0]
if v_0.Op != Op386ADDL {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
if !(ptr.Op != OpSB) {
break
}
v.reset(Op386MOVLloadidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(mem)
return true
}
// match: (MOVLload [off] {sym} (SB) _)
// cond: symIsRO(sym)
// result: (MOVLconst [int64(int32(read32(sym, off, config.BigEndian)))])
@ -6814,6 +6910,32 @@ func rewriteValue386_Op386MOVLstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVLstore [off] {sym} (ADDL idx ptr) val mem)
// cond: ptr.Op != OpSB
// result: (MOVLstoreidx1 [off] {sym} ptr idx val mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
v_0 := v.Args[0]
if v_0.Op != Op386ADDL {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
val := v.Args[1]
if !(ptr.Op != OpSB) {
break
}
v.reset(Op386MOVLstoreidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(val)
v.AddArg(mem)
return true
}
// match: (MOVLstore {sym} [off] ptr y:(ADDLload x [off] {sym} ptr mem) mem)
// cond: y.Uses==1 && clobber(y)
// result: (ADDLmodify [off] {sym} ptr x mem)
@ -6889,6 +7011,9 @@ func rewriteValue386_Op386MOVLstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValue386_Op386MOVLstore_10(v *Value) bool {
// match: (MOVLstore {sym} [off] ptr y:(XORLload x [off] {sym} ptr mem) mem)
// cond: y.Uses==1 && clobber(y)
// result: (XORLmodify [off] {sym} ptr x mem)
@ -6914,9 +7039,6 @@ func rewriteValue386_Op386MOVLstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValue386_Op386MOVLstore_10(v *Value) bool {
// match: (MOVLstore {sym} [off] ptr y:(ADDL l:(MOVLload [off] {sym} ptr mem) x) mem)
// cond: y.Uses==1 && l.Uses==1 && clobber(y) && clobber(l)
// result: (ADDLmodify [off] {sym} ptr x mem)
@ -7182,6 +7304,9 @@ func rewriteValue386_Op386MOVLstore_10(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValue386_Op386MOVLstore_20(v *Value) bool {
// match: (MOVLstore {sym} [off] ptr y:(ADDLconst [c] l:(MOVLload [off] {sym} ptr mem)) mem)
// cond: y.Uses==1 && l.Uses==1 && clobber(y) && clobber(l) && validValAndOff(c,off)
// result: (ADDLconstmodify [makeValAndOff(c,off)] {sym} ptr mem)
@ -7210,9 +7335,6 @@ func rewriteValue386_Op386MOVLstore_10(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValue386_Op386MOVLstore_20(v *Value) bool {
// match: (MOVLstore {sym} [off] ptr y:(ANDLconst [c] l:(MOVLload [off] {sym} ptr mem)) mem)
// cond: y.Uses==1 && l.Uses==1 && clobber(y) && clobber(l) && validValAndOff(c,off)
// result: (ANDLconstmodify [makeValAndOff(c,off)] {sym} ptr mem)
@ -8381,6 +8503,30 @@ func rewriteValue386_Op386MOVSDload_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVSDload [off] {sym} (ADDL idx ptr) mem)
// cond: ptr.Op != OpSB
// result: (MOVSDloadidx1 [off] {sym} ptr idx mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[1]
v_0 := v.Args[0]
if v_0.Op != Op386ADDL {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
if !(ptr.Op != OpSB) {
break
}
v.reset(Op386MOVSDloadidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(mem)
return true
}
return false
}
func rewriteValue386_Op386MOVSDloadidx1_0(v *Value) bool {
@ -8609,6 +8755,32 @@ func rewriteValue386_Op386MOVSDstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVSDstore [off] {sym} (ADDL idx ptr) val mem)
// cond: ptr.Op != OpSB
// result: (MOVSDstoreidx1 [off] {sym} ptr idx val mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
v_0 := v.Args[0]
if v_0.Op != Op386ADDL {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
val := v.Args[1]
if !(ptr.Op != OpSB) {
break
}
v.reset(Op386MOVSDstoreidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(val)
v.AddArg(mem)
return true
}
return false
}
func rewriteValue386_Op386MOVSDstoreidx1_0(v *Value) bool {
@ -8855,6 +9027,30 @@ func rewriteValue386_Op386MOVSSload_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVSSload [off] {sym} (ADDL idx ptr) mem)
// cond: ptr.Op != OpSB
// result: (MOVSSloadidx1 [off] {sym} ptr idx mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[1]
v_0 := v.Args[0]
if v_0.Op != Op386ADDL {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
if !(ptr.Op != OpSB) {
break
}
v.reset(Op386MOVSSloadidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(mem)
return true
}
return false
}
func rewriteValue386_Op386MOVSSloadidx1_0(v *Value) bool {
@ -9083,6 +9279,32 @@ func rewriteValue386_Op386MOVSSstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVSSstore [off] {sym} (ADDL idx ptr) val mem)
// cond: ptr.Op != OpSB
// result: (MOVSSstoreidx1 [off] {sym} ptr idx val mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
v_0 := v.Args[0]
if v_0.Op != Op386ADDL {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
val := v.Args[1]
if !(ptr.Op != OpSB) {
break
}
v.reset(Op386MOVSSstoreidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(val)
v.AddArg(mem)
return true
}
return false
}
func rewriteValue386_Op386MOVSSstoreidx1_0(v *Value) bool {
@ -9530,6 +9752,30 @@ func rewriteValue386_Op386MOVWload_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVWload [off] {sym} (ADDL idx ptr) mem)
// cond: ptr.Op != OpSB
// result: (MOVWloadidx1 [off] {sym} ptr idx mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[1]
v_0 := v.Args[0]
if v_0.Op != Op386ADDL {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
if !(ptr.Op != OpSB) {
break
}
v.reset(Op386MOVWloadidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(mem)
return true
}
// match: (MOVWload [off] {sym} (SB) _)
// cond: symIsRO(sym)
// result: (MOVLconst [int64(read16(sym, off, config.BigEndian))])
@ -9918,6 +10164,32 @@ func rewriteValue386_Op386MOVWstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVWstore [off] {sym} (ADDL idx ptr) val mem)
// cond: ptr.Op != OpSB
// result: (MOVWstoreidx1 [off] {sym} ptr idx val mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
v_0 := v.Args[0]
if v_0.Op != Op386ADDL {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
val := v.Args[1]
if !(ptr.Op != OpSB) {
break
}
v.reset(Op386MOVWstoreidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(val)
v.AddArg(mem)
return true
}
// match: (MOVWstore [i] {s} p (SHRLconst [16] w) x:(MOVWstore [i-2] {s} p w mem))
// cond: x.Uses == 1 && clobber(x)
// result: (MOVLstore [i-2] {s} p w mem)
@ -9947,6 +10219,9 @@ func rewriteValue386_Op386MOVWstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValue386_Op386MOVWstore_10(v *Value) bool {
// match: (MOVWstore [i] {s} p (SHRLconst [j] w) x:(MOVWstore [i-2] {s} p w0:(SHRLconst [j-16] w) mem))
// cond: x.Uses == 1 && clobber(x)
// result: (MOVLstore [i-2] {s} p w0 mem)

View File

@ -301,7 +301,7 @@ func rewriteValueAMD64(v *Value) bool {
case OpAMD64MOVQi2f:
return rewriteValueAMD64_OpAMD64MOVQi2f_0(v)
case OpAMD64MOVQload:
return rewriteValueAMD64_OpAMD64MOVQload_0(v)
return rewriteValueAMD64_OpAMD64MOVQload_0(v) || rewriteValueAMD64_OpAMD64MOVQload_10(v)
case OpAMD64MOVQloadidx1:
return rewriteValueAMD64_OpAMD64MOVQloadidx1_0(v)
case OpAMD64MOVQloadidx8:
@ -10220,6 +10220,28 @@ func rewriteValueAMD64_OpAMD64LEAL_0(v *Value) bool {
v.AddArg(y)
return true
}
// match: (LEAL [c] {s} (ADDL y x))
// cond: x.Op != OpSB && y.Op != OpSB
// result: (LEAL1 [c] {s} x y)
for {
c := v.AuxInt
s := v.Aux
v_0 := v.Args[0]
if v_0.Op != OpAMD64ADDL {
break
}
x := v_0.Args[1]
y := v_0.Args[0]
if !(x.Op != OpSB && y.Op != OpSB) {
break
}
v.reset(OpAMD64LEAL1)
v.AuxInt = c
v.Aux = s
v.AddArg(x)
v.AddArg(y)
return true
}
return false
}
func rewriteValueAMD64_OpAMD64LEAL1_0(v *Value) bool {
@ -10634,6 +10656,28 @@ func rewriteValueAMD64_OpAMD64LEAQ_0(v *Value) bool {
v.AddArg(y)
return true
}
// match: (LEAQ [c] {s} (ADDQ y x))
// cond: x.Op != OpSB && y.Op != OpSB
// result: (LEAQ1 [c] {s} x y)
for {
c := v.AuxInt
s := v.Aux
v_0 := v.Args[0]
if v_0.Op != OpAMD64ADDQ {
break
}
x := v_0.Args[1]
y := v_0.Args[0]
if !(x.Op != OpSB && y.Op != OpSB) {
break
}
v.reset(OpAMD64LEAQ1)
v.AuxInt = c
v.Aux = s
v.AddArg(x)
v.AddArg(y)
return true
}
// match: (LEAQ [off1] {sym1} (LEAQ [off2] {sym2} x))
// cond: is32Bit(off1+off2) && canMergeSym(sym1, sym2)
// result: (LEAQ [off1+off2] {mergeSym(sym1,sym2)} x)
@ -11770,6 +11814,30 @@ func rewriteValueAMD64_OpAMD64MOVBload_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVBload [off] {sym} (ADDQ idx ptr) mem)
// cond: ptr.Op != OpSB
// result: (MOVBloadidx1 [off] {sym} ptr idx mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[1]
v_0 := v.Args[0]
if v_0.Op != OpAMD64ADDQ {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpAMD64MOVBloadidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(mem)
return true
}
// match: (MOVBload [off1] {sym1} (LEAL [off2] {sym2} base) mem)
// cond: canMergeSym(sym1, sym2) && is32Bit(off1+off2)
// result: (MOVBload [off1+off2] {mergeSym(sym1,sym2)} base mem)
@ -12419,6 +12487,32 @@ func rewriteValueAMD64_OpAMD64MOVBstore_10(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVBstore [off] {sym} (ADDQ idx ptr) val mem)
// cond: ptr.Op != OpSB
// result: (MOVBstoreidx1 [off] {sym} ptr idx val mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
v_0 := v.Args[0]
if v_0.Op != OpAMD64ADDQ {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
val := v.Args[1]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpAMD64MOVBstoreidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(val)
v.AddArg(mem)
return true
}
// match: (MOVBstore [i] {s} p w x0:(MOVBstore [i-1] {s} p (SHRWconst [8] w) mem))
// cond: x0.Uses == 1 && clobber(x0)
// result: (MOVWstore [i-1] {s} p (ROLWconst <w.Type> [8] w) mem)
@ -12451,6 +12545,10 @@ func rewriteValueAMD64_OpAMD64MOVBstore_10(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueAMD64_OpAMD64MOVBstore_20(v *Value) bool {
b := v.Block
// match: (MOVBstore [i] {s} p w x2:(MOVBstore [i-1] {s} p (SHRLconst [8] w) x1:(MOVBstore [i-2] {s} p (SHRLconst [16] w) x0:(MOVBstore [i-3] {s} p (SHRLconst [24] w) mem))))
// cond: x0.Uses == 1 && x1.Uses == 1 && x2.Uses == 1 && clobber(x0) && clobber(x1) && clobber(x2)
// result: (MOVLstore [i-3] {s} p (BSWAPL <w.Type> w) mem)
@ -12506,11 +12604,6 @@ func rewriteValueAMD64_OpAMD64MOVBstore_10(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueAMD64_OpAMD64MOVBstore_20(v *Value) bool {
b := v.Block
typ := &b.Func.Config.Types
// match: (MOVBstore [i] {s} p w x6:(MOVBstore [i-1] {s} p (SHRQconst [8] w) x5:(MOVBstore [i-2] {s} p (SHRQconst [16] w) x4:(MOVBstore [i-3] {s} p (SHRQconst [24] w) x3:(MOVBstore [i-4] {s} p (SHRQconst [32] w) x2:(MOVBstore [i-5] {s} p (SHRQconst [40] w) x1:(MOVBstore [i-6] {s} p (SHRQconst [48] w) x0:(MOVBstore [i-7] {s} p (SHRQconst [56] w) mem))))))))
// cond: x0.Uses == 1 && x1.Uses == 1 && x2.Uses == 1 && x3.Uses == 1 && x4.Uses == 1 && x5.Uses == 1 && x6.Uses == 1 && clobber(x0) && clobber(x1) && clobber(x2) && clobber(x3) && clobber(x4) && clobber(x5) && clobber(x6)
// result: (MOVQstore [i-7] {s} p (BSWAPQ <w.Type> w) mem)
@ -12856,6 +12949,11 @@ func rewriteValueAMD64_OpAMD64MOVBstore_20(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueAMD64_OpAMD64MOVBstore_30(v *Value) bool {
b := v.Block
typ := &b.Func.Config.Types
// match: (MOVBstore [i] {s} p x1:(MOVBload [j] {s2} p2 mem) mem2:(MOVBstore [i-1] {s} p x2:(MOVBload [j-1] {s2} p2 mem) mem))
// cond: x1.Uses == 1 && x2.Uses == 1 && mem2.Uses == 1 && clobber(x1) && clobber(x2) && clobber(mem2)
// result: (MOVWstore [i-1] {s} p (MOVWload [j-1] {s2} p2 mem) mem)
@ -12901,9 +12999,6 @@ func rewriteValueAMD64_OpAMD64MOVBstore_20(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueAMD64_OpAMD64MOVBstore_30(v *Value) bool {
// match: (MOVBstore [off1] {sym1} (LEAL [off2] {sym2} base) val mem)
// cond: canMergeSym(sym1, sym2) && is32Bit(off1+off2)
// result: (MOVBstore [off1+off2] {mergeSym(sym1,sym2)} base val mem)
@ -14291,6 +14386,30 @@ func rewriteValueAMD64_OpAMD64MOVLload_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVLload [off] {sym} (ADDQ idx ptr) mem)
// cond: ptr.Op != OpSB
// result: (MOVLloadidx1 [off] {sym} ptr idx mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[1]
v_0 := v.Args[0]
if v_0.Op != OpAMD64ADDQ {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpAMD64MOVLloadidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(mem)
return true
}
// match: (MOVLload [off1] {sym1} (LEAL [off2] {sym2} base) mem)
// cond: canMergeSym(sym1, sym2) && is32Bit(off1+off2)
// result: (MOVLload [off1+off2] {mergeSym(sym1,sym2)} base mem)
@ -14338,6 +14457,11 @@ func rewriteValueAMD64_OpAMD64MOVLload_0(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueAMD64_OpAMD64MOVLload_10(v *Value) bool {
b := v.Block
config := b.Func.Config
// match: (MOVLload [off] {sym} ptr (MOVSSstore [off] {sym} ptr val _))
// result: (MOVLf2i val)
for {
@ -14358,11 +14482,6 @@ func rewriteValueAMD64_OpAMD64MOVLload_0(v *Value) bool {
v.AddArg(val)
return true
}
return false
}
func rewriteValueAMD64_OpAMD64MOVLload_10(v *Value) bool {
b := v.Block
config := b.Func.Config
// match: (MOVLload [off] {sym} (SB) _)
// cond: symIsRO(sym)
// result: (MOVQconst [int64(read32(sym, off, config.BigEndian))])
@ -15014,6 +15133,32 @@ func rewriteValueAMD64_OpAMD64MOVLstore_0(v *Value) bool {
func rewriteValueAMD64_OpAMD64MOVLstore_10(v *Value) bool {
b := v.Block
typ := &b.Func.Config.Types
// match: (MOVLstore [off] {sym} (ADDQ idx ptr) val mem)
// cond: ptr.Op != OpSB
// result: (MOVLstoreidx1 [off] {sym} ptr idx val mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
v_0 := v.Args[0]
if v_0.Op != OpAMD64ADDQ {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
val := v.Args[1]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpAMD64MOVLstoreidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(val)
v.AddArg(mem)
return true
}
// match: (MOVLstore [i] {s} p (SHRQconst [32] w) x:(MOVLstore [i-4] {s} p w mem))
// cond: x.Uses == 1 && clobber(x)
// result: (MOVQstore [i-4] {s} p w mem)
@ -15273,6 +15418,9 @@ func rewriteValueAMD64_OpAMD64MOVLstore_10(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueAMD64_OpAMD64MOVLstore_20(v *Value) bool {
// match: (MOVLstore {sym} [off] ptr y:(ADDL l:(MOVLload [off] {sym} ptr mem) x) mem)
// cond: y.Uses==1 && l.Uses==1 && clobber(y) && clobber(l)
// result: (ADDLmodify [off] {sym} ptr x mem)
@ -15302,9 +15450,6 @@ func rewriteValueAMD64_OpAMD64MOVLstore_10(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueAMD64_OpAMD64MOVLstore_20(v *Value) bool {
// match: (MOVLstore {sym} [off] ptr y:(ADDL x l:(MOVLload [off] {sym} ptr mem)) mem)
// cond: y.Uses==1 && l.Uses==1 && clobber(y) && clobber(l)
// result: (ADDLmodify [off] {sym} ptr x mem)
@ -15570,6 +15715,9 @@ func rewriteValueAMD64_OpAMD64MOVLstore_20(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueAMD64_OpAMD64MOVLstore_30(v *Value) bool {
// match: (MOVLstore {sym} [off] ptr y:(BTRL l:(MOVLload [off] {sym} ptr mem) x) mem)
// cond: y.Uses==1 && l.Uses==1 && clobber(y) && clobber(l)
// result: (BTRLmodify [off] {sym} ptr x mem)
@ -15599,9 +15747,6 @@ func rewriteValueAMD64_OpAMD64MOVLstore_20(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueAMD64_OpAMD64MOVLstore_30(v *Value) bool {
// match: (MOVLstore {sym} [off] ptr y:(BTSL l:(MOVLload [off] {sym} ptr mem) x) mem)
// cond: y.Uses==1 && l.Uses==1 && clobber(y) && clobber(l)
// result: (BTSLmodify [off] {sym} ptr x mem)
@ -16924,8 +17069,6 @@ func rewriteValueAMD64_OpAMD64MOVQi2f_0(v *Value) bool {
return false
}
func rewriteValueAMD64_OpAMD64MOVQload_0(v *Value) bool {
b := v.Block
config := b.Func.Config
// match: (MOVQload [off] {sym} ptr (MOVQstore [off2] {sym2} ptr2 x _))
// cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)
// result: x
@ -17074,6 +17217,30 @@ func rewriteValueAMD64_OpAMD64MOVQload_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVQload [off] {sym} (ADDQ idx ptr) mem)
// cond: ptr.Op != OpSB
// result: (MOVQloadidx1 [off] {sym} ptr idx mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[1]
v_0 := v.Args[0]
if v_0.Op != OpAMD64ADDQ {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpAMD64MOVQloadidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(mem)
return true
}
// match: (MOVQload [off1] {sym1} (LEAL [off2] {sym2} base) mem)
// cond: canMergeSym(sym1, sym2) && is32Bit(off1+off2)
// result: (MOVQload [off1+off2] {mergeSym(sym1,sym2)} base mem)
@ -17141,6 +17308,11 @@ func rewriteValueAMD64_OpAMD64MOVQload_0(v *Value) bool {
v.AddArg(val)
return true
}
return false
}
func rewriteValueAMD64_OpAMD64MOVQload_10(v *Value) bool {
b := v.Block
config := b.Func.Config
// match: (MOVQload [off] {sym} (SB) _)
// cond: symIsRO(sym)
// result: (MOVQconst [int64(read64(sym, off, config.BigEndian))])
@ -17580,6 +17752,32 @@ func rewriteValueAMD64_OpAMD64MOVQstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVQstore [off] {sym} (ADDQ idx ptr) val mem)
// cond: ptr.Op != OpSB
// result: (MOVQstoreidx1 [off] {sym} ptr idx val mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
v_0 := v.Args[0]
if v_0.Op != OpAMD64ADDQ {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
val := v.Args[1]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpAMD64MOVQstoreidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(val)
v.AddArg(mem)
return true
}
// match: (MOVQstore [off1] {sym1} (LEAL [off2] {sym2} base) val mem)
// cond: canMergeSym(sym1, sym2) && is32Bit(off1+off2)
// result: (MOVQstore [off1+off2] {mergeSym(sym1,sym2)} base val mem)
@ -17656,6 +17854,9 @@ func rewriteValueAMD64_OpAMD64MOVQstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueAMD64_OpAMD64MOVQstore_10(v *Value) bool {
// match: (MOVQstore {sym} [off] ptr y:(ANDQload x [off] {sym} ptr mem) mem)
// cond: y.Uses==1 && clobber(y)
// result: (ANDQmodify [off] {sym} ptr x mem)
@ -17681,9 +17882,6 @@ func rewriteValueAMD64_OpAMD64MOVQstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueAMD64_OpAMD64MOVQstore_10(v *Value) bool {
// match: (MOVQstore {sym} [off] ptr y:(ORQload x [off] {sym} ptr mem) mem)
// cond: y.Uses==1 && clobber(y)
// result: (ORQmodify [off] {sym} ptr x mem)
@ -17940,6 +18138,9 @@ func rewriteValueAMD64_OpAMD64MOVQstore_10(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueAMD64_OpAMD64MOVQstore_20(v *Value) bool {
// match: (MOVQstore {sym} [off] ptr y:(XORQ l:(MOVQload [off] {sym} ptr mem) x) mem)
// cond: y.Uses==1 && l.Uses==1 && clobber(y) && clobber(l)
// result: (XORQmodify [off] {sym} ptr x mem)
@ -17969,9 +18170,6 @@ func rewriteValueAMD64_OpAMD64MOVQstore_10(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueAMD64_OpAMD64MOVQstore_20(v *Value) bool {
// match: (MOVQstore {sym} [off] ptr y:(XORQ x l:(MOVQload [off] {sym} ptr mem)) mem)
// cond: y.Uses==1 && l.Uses==1 && clobber(y) && clobber(l)
// result: (XORQmodify [off] {sym} ptr x mem)
@ -18234,6 +18432,9 @@ func rewriteValueAMD64_OpAMD64MOVQstore_20(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueAMD64_OpAMD64MOVQstore_30(v *Value) bool {
// match: (MOVQstore [off] {sym} ptr a:(BTRQconst [c] l:(MOVQload [off] {sym} ptr2 mem)) mem)
// cond: isSamePtr(ptr, ptr2) && a.Uses == 1 && l.Uses == 1 && validValAndOff(c,off) && clobber(l) && clobber(a)
// result: (BTRQconstmodify {sym} [makeValAndOff(c,off)] ptr mem)
@ -18263,9 +18464,6 @@ func rewriteValueAMD64_OpAMD64MOVQstore_20(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueAMD64_OpAMD64MOVQstore_30(v *Value) bool {
// match: (MOVQstore [off] {sym} ptr a:(BTSQconst [c] l:(MOVQload [off] {sym} ptr2 mem)) mem)
// cond: isSamePtr(ptr, ptr2) && a.Uses == 1 && l.Uses == 1 && validValAndOff(c,off) && clobber(l) && clobber(a)
// result: (BTSQconstmodify {sym} [makeValAndOff(c,off)] ptr mem)
@ -18954,6 +19152,30 @@ func rewriteValueAMD64_OpAMD64MOVSDload_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVSDload [off] {sym} (ADDQ idx ptr) mem)
// cond: ptr.Op != OpSB
// result: (MOVSDloadidx1 [off] {sym} ptr idx mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[1]
v_0 := v.Args[0]
if v_0.Op != OpAMD64ADDQ {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpAMD64MOVSDloadidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(mem)
return true
}
// match: (MOVSDload [off] {sym} ptr (MOVQstore [off] {sym} ptr val _))
// result: (MOVQi2f val)
for {
@ -19282,6 +19504,32 @@ func rewriteValueAMD64_OpAMD64MOVSDstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVSDstore [off] {sym} (ADDQ idx ptr) val mem)
// cond: ptr.Op != OpSB
// result: (MOVSDstoreidx1 [off] {sym} ptr idx val mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
v_0 := v.Args[0]
if v_0.Op != OpAMD64ADDQ {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
val := v.Args[1]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpAMD64MOVSDstoreidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(val)
v.AddArg(mem)
return true
}
// match: (MOVSDstore [off] {sym} ptr (MOVQi2f val) mem)
// result: (MOVQstore [off] {sym} ptr val mem)
for {
@ -19614,6 +19862,30 @@ func rewriteValueAMD64_OpAMD64MOVSSload_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVSSload [off] {sym} (ADDQ idx ptr) mem)
// cond: ptr.Op != OpSB
// result: (MOVSSloadidx1 [off] {sym} ptr idx mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[1]
v_0 := v.Args[0]
if v_0.Op != OpAMD64ADDQ {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpAMD64MOVSSloadidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(mem)
return true
}
// match: (MOVSSload [off] {sym} ptr (MOVLstore [off] {sym} ptr val _))
// result: (MOVLi2f val)
for {
@ -19942,6 +20214,32 @@ func rewriteValueAMD64_OpAMD64MOVSSstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVSSstore [off] {sym} (ADDQ idx ptr) val mem)
// cond: ptr.Op != OpSB
// result: (MOVSSstoreidx1 [off] {sym} ptr idx val mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
v_0 := v.Args[0]
if v_0.Op != OpAMD64ADDQ {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
val := v.Args[1]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpAMD64MOVSSstoreidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(val)
v.AddArg(mem)
return true
}
// match: (MOVSSstore [off] {sym} ptr (MOVLi2f val) mem)
// result: (MOVLstore [off] {sym} ptr val mem)
for {
@ -20656,6 +20954,30 @@ func rewriteValueAMD64_OpAMD64MOVWload_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVWload [off] {sym} (ADDQ idx ptr) mem)
// cond: ptr.Op != OpSB
// result: (MOVWloadidx1 [off] {sym} ptr idx mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[1]
v_0 := v.Args[0]
if v_0.Op != OpAMD64ADDQ {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpAMD64MOVWloadidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(mem)
return true
}
// match: (MOVWload [off1] {sym1} (LEAL [off2] {sym2} base) mem)
// cond: canMergeSym(sym1, sym2) && is32Bit(off1+off2)
// result: (MOVWload [off1+off2] {mergeSym(sym1,sym2)} base mem)
@ -21205,6 +21527,37 @@ func rewriteValueAMD64_OpAMD64MOVWstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVWstore [off] {sym} (ADDQ idx ptr) val mem)
// cond: ptr.Op != OpSB
// result: (MOVWstoreidx1 [off] {sym} ptr idx val mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
v_0 := v.Args[0]
if v_0.Op != OpAMD64ADDQ {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
val := v.Args[1]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpAMD64MOVWstoreidx1)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(val)
v.AddArg(mem)
return true
}
return false
}
func rewriteValueAMD64_OpAMD64MOVWstore_10(v *Value) bool {
b := v.Block
typ := &b.Func.Config.Types
// match: (MOVWstore [i] {s} p (SHRLconst [16] w) x:(MOVWstore [i-2] {s} p w mem))
// cond: x.Uses == 1 && clobber(x)
// result: (MOVLstore [i-2] {s} p w mem)
@ -21234,11 +21587,6 @@ func rewriteValueAMD64_OpAMD64MOVWstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueAMD64_OpAMD64MOVWstore_10(v *Value) bool {
b := v.Block
typ := &b.Func.Config.Types
// match: (MOVWstore [i] {s} p (SHRQconst [16] w) x:(MOVWstore [i-2] {s} p w mem))
// cond: x.Uses == 1 && clobber(x)
// result: (MOVLstore [i-2] {s} p w mem)

File diff suppressed because it is too large Load Diff

View File

@ -1848,6 +1848,26 @@ func rewriteValuePPC64_OpEq16_0(v *Value) bool {
v.AddArg(v0)
return true
}
// match: (Eq16 y x)
// cond: isSigned(x.Type) && isSigned(y.Type)
// result: (Equal (CMPW (SignExt16to32 x) (SignExt16to32 y)))
for {
x := v.Args[1]
y := v.Args[0]
if !(isSigned(x.Type) && isSigned(y.Type)) {
break
}
v.reset(OpPPC64Equal)
v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags)
v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32)
v1.AddArg(x)
v0.AddArg(v1)
v2 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32)
v2.AddArg(y)
v0.AddArg(v2)
v.AddArg(v0)
return true
}
// match: (Eq16 x y)
// result: (Equal (CMPW (ZeroExt16to32 x) (ZeroExt16to32 y)))
for {
@ -1948,6 +1968,26 @@ func rewriteValuePPC64_OpEq8_0(v *Value) bool {
v.AddArg(v0)
return true
}
// match: (Eq8 y x)
// cond: isSigned(x.Type) && isSigned(y.Type)
// result: (Equal (CMPW (SignExt8to32 x) (SignExt8to32 y)))
for {
x := v.Args[1]
y := v.Args[0]
if !(isSigned(x.Type) && isSigned(y.Type)) {
break
}
v.reset(OpPPC64Equal)
v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags)
v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32)
v1.AddArg(x)
v0.AddArg(v1)
v2 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32)
v2.AddArg(y)
v0.AddArg(v2)
v.AddArg(v0)
return true
}
// match: (Eq8 x y)
// result: (Equal (CMPW (ZeroExt8to32 x) (ZeroExt8to32 y)))
for {
@ -4677,6 +4717,26 @@ func rewriteValuePPC64_OpNeq16_0(v *Value) bool {
v.AddArg(v0)
return true
}
// match: (Neq16 y x)
// cond: isSigned(x.Type) && isSigned(y.Type)
// result: (NotEqual (CMPW (SignExt16to32 x) (SignExt16to32 y)))
for {
x := v.Args[1]
y := v.Args[0]
if !(isSigned(x.Type) && isSigned(y.Type)) {
break
}
v.reset(OpPPC64NotEqual)
v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags)
v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32)
v1.AddArg(x)
v0.AddArg(v1)
v2 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32)
v2.AddArg(y)
v0.AddArg(v2)
v.AddArg(v0)
return true
}
// match: (Neq16 x y)
// result: (NotEqual (CMPW (ZeroExt16to32 x) (ZeroExt16to32 y)))
for {
@ -4777,6 +4837,26 @@ func rewriteValuePPC64_OpNeq8_0(v *Value) bool {
v.AddArg(v0)
return true
}
// match: (Neq8 y x)
// cond: isSigned(x.Type) && isSigned(y.Type)
// result: (NotEqual (CMPW (SignExt8to32 x) (SignExt8to32 y)))
for {
x := v.Args[1]
y := v.Args[0]
if !(isSigned(x.Type) && isSigned(y.Type)) {
break
}
v.reset(OpPPC64NotEqual)
v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags)
v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32)
v1.AddArg(x)
v0.AddArg(v1)
v2 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32)
v2.AddArg(y)
v0.AddArg(v2)
v.AddArg(v0)
return true
}
// match: (Neq8 x y)
// result: (NotEqual (CMPW (ZeroExt8to32 x) (ZeroExt8to32 y)))
for {

View File

@ -9331,6 +9331,30 @@ func rewriteValueS390X_OpS390XFMOVDload_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (FMOVDload [off] {sym} (ADD idx ptr) mem)
// cond: ptr.Op != OpSB
// result: (FMOVDloadidx [off] {sym} ptr idx mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[1]
v_0 := v.Args[0]
if v_0.Op != OpS390XADD {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpS390XFMOVDloadidx)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(mem)
return true
}
return false
}
func rewriteValueS390X_OpS390XFMOVDloadidx_0(v *Value) bool {
@ -9492,6 +9516,32 @@ func rewriteValueS390X_OpS390XFMOVDstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (FMOVDstore [off] {sym} (ADD idx ptr) val mem)
// cond: ptr.Op != OpSB
// result: (FMOVDstoreidx [off] {sym} ptr idx val mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
v_0 := v.Args[0]
if v_0.Op != OpS390XADD {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
val := v.Args[1]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpS390XFMOVDstoreidx)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(val)
v.AddArg(mem)
return true
}
return false
}
func rewriteValueS390X_OpS390XFMOVDstoreidx_0(v *Value) bool {
@ -9672,6 +9722,30 @@ func rewriteValueS390X_OpS390XFMOVSload_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (FMOVSload [off] {sym} (ADD idx ptr) mem)
// cond: ptr.Op != OpSB
// result: (FMOVSloadidx [off] {sym} ptr idx mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[1]
v_0 := v.Args[0]
if v_0.Op != OpS390XADD {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpS390XFMOVSloadidx)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(mem)
return true
}
return false
}
func rewriteValueS390X_OpS390XFMOVSloadidx_0(v *Value) bool {
@ -9833,6 +9907,32 @@ func rewriteValueS390X_OpS390XFMOVSstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (FMOVSstore [off] {sym} (ADD idx ptr) val mem)
// cond: ptr.Op != OpSB
// result: (FMOVSstoreidx [off] {sym} ptr idx val mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
v_0 := v.Args[0]
if v_0.Op != OpS390XADD {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
val := v.Args[1]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpS390XFMOVSstoreidx)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(val)
v.AddArg(mem)
return true
}
return false
}
func rewriteValueS390X_OpS390XFMOVSstoreidx_0(v *Value) bool {
@ -10484,6 +10584,30 @@ func rewriteValueS390X_OpS390XMOVBZload_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVBZload [off] {sym} (ADD idx ptr) mem)
// cond: ptr.Op != OpSB
// result: (MOVBZloadidx [off] {sym} ptr idx mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[1]
v_0 := v.Args[0]
if v_0.Op != OpS390XADD {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpS390XMOVBZloadidx)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(mem)
return true
}
return false
}
func rewriteValueS390X_OpS390XMOVBZloadidx_0(v *Value) bool {
@ -10974,6 +11098,30 @@ func rewriteValueS390X_OpS390XMOVBload_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVBload [off] {sym} (ADD idx ptr) mem)
// cond: ptr.Op != OpSB
// result: (MOVBloadidx [off] {sym} ptr idx mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[1]
v_0 := v.Args[0]
if v_0.Op != OpS390XADD {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpS390XMOVBloadidx)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(mem)
return true
}
return false
}
func rewriteValueS390X_OpS390XMOVBloadidx_0(v *Value) bool {
@ -11490,6 +11638,32 @@ func rewriteValueS390X_OpS390XMOVBstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVBstore [off] {sym} (ADD idx ptr) val mem)
// cond: ptr.Op != OpSB
// result: (MOVBstoreidx [off] {sym} ptr idx val mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
v_0 := v.Args[0]
if v_0.Op != OpS390XADD {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
val := v.Args[1]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpS390XMOVBstoreidx)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(val)
v.AddArg(mem)
return true
}
// match: (MOVBstore [i] {s} p w x:(MOVBstore [i-1] {s} p (SRDconst [8] w) mem))
// cond: p.Op != OpSB && x.Uses == 1 && clobber(x)
// result: (MOVHstore [i-1] {s} p w mem)
@ -11553,6 +11727,9 @@ func rewriteValueS390X_OpS390XMOVBstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueS390X_OpS390XMOVBstore_10(v *Value) bool {
// match: (MOVBstore [i] {s} p w x:(MOVBstore [i-1] {s} p (SRWconst [8] w) mem))
// cond: p.Op != OpSB && x.Uses == 1 && clobber(x)
// result: (MOVHstore [i-1] {s} p w mem)
@ -11582,9 +11759,6 @@ func rewriteValueS390X_OpS390XMOVBstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueS390X_OpS390XMOVBstore_10(v *Value) bool {
// match: (MOVBstore [i] {s} p w0:(SRWconst [j] w) x:(MOVBstore [i-1] {s} p (SRWconst [j+8] w) mem))
// cond: p.Op != OpSB && x.Uses == 1 && clobber(x)
// result: (MOVHstore [i-1] {s} p w0 mem)
@ -13259,6 +13433,30 @@ func rewriteValueS390X_OpS390XMOVDload_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVDload [off] {sym} (ADD idx ptr) mem)
// cond: ptr.Op != OpSB
// result: (MOVDloadidx [off] {sym} ptr idx mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[1]
v_0 := v.Args[0]
if v_0.Op != OpS390XADD {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpS390XMOVDloadidx)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(mem)
return true
}
return false
}
func rewriteValueS390X_OpS390XMOVDloadidx_0(v *Value) bool {
@ -13494,6 +13692,32 @@ func rewriteValueS390X_OpS390XMOVDstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVDstore [off] {sym} (ADD idx ptr) val mem)
// cond: ptr.Op != OpSB
// result: (MOVDstoreidx [off] {sym} ptr idx val mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
v_0 := v.Args[0]
if v_0.Op != OpS390XADD {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
val := v.Args[1]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpS390XMOVDstoreidx)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(val)
v.AddArg(mem)
return true
}
// match: (MOVDstore [i] {s} p w1 x:(MOVDstore [i-8] {s} p w0 mem))
// cond: p.Op != OpSB && x.Uses == 1 && is20Bit(i-8) && clobber(x)
// result: (STMG2 [i-8] {s} p w0 w1 mem)
@ -14545,6 +14769,30 @@ func rewriteValueS390X_OpS390XMOVHZload_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVHZload [off] {sym} (ADD idx ptr) mem)
// cond: ptr.Op != OpSB
// result: (MOVHZloadidx [off] {sym} ptr idx mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[1]
v_0 := v.Args[0]
if v_0.Op != OpS390XADD {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpS390XMOVHZloadidx)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(mem)
return true
}
return false
}
func rewriteValueS390X_OpS390XMOVHZloadidx_0(v *Value) bool {
@ -15027,6 +15275,30 @@ func rewriteValueS390X_OpS390XMOVHload_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVHload [off] {sym} (ADD idx ptr) mem)
// cond: ptr.Op != OpSB
// result: (MOVHloadidx [off] {sym} ptr idx mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[1]
v_0 := v.Args[0]
if v_0.Op != OpS390XADD {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpS390XMOVHloadidx)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(mem)
return true
}
return false
}
func rewriteValueS390X_OpS390XMOVHloadidx_0(v *Value) bool {
@ -15595,6 +15867,32 @@ func rewriteValueS390X_OpS390XMOVHstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVHstore [off] {sym} (ADD idx ptr) val mem)
// cond: ptr.Op != OpSB
// result: (MOVHstoreidx [off] {sym} ptr idx val mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
v_0 := v.Args[0]
if v_0.Op != OpS390XADD {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
val := v.Args[1]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpS390XMOVHstoreidx)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(val)
v.AddArg(mem)
return true
}
// match: (MOVHstore [i] {s} p w x:(MOVHstore [i-2] {s} p (SRDconst [16] w) mem))
// cond: p.Op != OpSB && x.Uses == 1 && clobber(x)
// result: (MOVWstore [i-2] {s} p w mem)
@ -15658,6 +15956,9 @@ func rewriteValueS390X_OpS390XMOVHstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueS390X_OpS390XMOVHstore_10(v *Value) bool {
// match: (MOVHstore [i] {s} p w x:(MOVHstore [i-2] {s} p (SRWconst [16] w) mem))
// cond: p.Op != OpSB && x.Uses == 1 && clobber(x)
// result: (MOVWstore [i-2] {s} p w mem)
@ -15687,9 +15988,6 @@ func rewriteValueS390X_OpS390XMOVHstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueS390X_OpS390XMOVHstore_10(v *Value) bool {
// match: (MOVHstore [i] {s} p w0:(SRWconst [j] w) x:(MOVHstore [i-2] {s} p (SRWconst [j+16] w) mem))
// cond: p.Op != OpSB && x.Uses == 1 && clobber(x)
// result: (MOVWstore [i-2] {s} p w0 mem)
@ -16916,6 +17214,30 @@ func rewriteValueS390X_OpS390XMOVWZload_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVWZload [off] {sym} (ADD idx ptr) mem)
// cond: ptr.Op != OpSB
// result: (MOVWZloadidx [off] {sym} ptr idx mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[1]
v_0 := v.Args[0]
if v_0.Op != OpS390XADD {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpS390XMOVWZloadidx)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(mem)
return true
}
return false
}
func rewriteValueS390X_OpS390XMOVWZloadidx_0(v *Value) bool {
@ -17398,6 +17720,30 @@ func rewriteValueS390X_OpS390XMOVWload_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVWload [off] {sym} (ADD idx ptr) mem)
// cond: ptr.Op != OpSB
// result: (MOVWloadidx [off] {sym} ptr idx mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[1]
v_0 := v.Args[0]
if v_0.Op != OpS390XADD {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpS390XMOVWloadidx)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(mem)
return true
}
return false
}
func rewriteValueS390X_OpS390XMOVWloadidx_0(v *Value) bool {
@ -17997,6 +18343,32 @@ func rewriteValueS390X_OpS390XMOVWstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
// match: (MOVWstore [off] {sym} (ADD idx ptr) val mem)
// cond: ptr.Op != OpSB
// result: (MOVWstoreidx [off] {sym} ptr idx val mem)
for {
off := v.AuxInt
sym := v.Aux
mem := v.Args[2]
v_0 := v.Args[0]
if v_0.Op != OpS390XADD {
break
}
ptr := v_0.Args[1]
idx := v_0.Args[0]
val := v.Args[1]
if !(ptr.Op != OpSB) {
break
}
v.reset(OpS390XMOVWstoreidx)
v.AuxInt = off
v.Aux = sym
v.AddArg(ptr)
v.AddArg(idx)
v.AddArg(val)
v.AddArg(mem)
return true
}
// match: (MOVWstore [i] {s} p (SRDconst [32] w) x:(MOVWstore [i-4] {s} p w mem))
// cond: p.Op != OpSB && x.Uses == 1 && clobber(x)
// result: (MOVDstore [i-4] {s} p w mem)
@ -18060,6 +18432,9 @@ func rewriteValueS390X_OpS390XMOVWstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueS390X_OpS390XMOVWstore_10(v *Value) bool {
// match: (MOVWstore [i] {s} p w1 x:(MOVWstore [i-4] {s} p w0 mem))
// cond: p.Op != OpSB && x.Uses == 1 && is20Bit(i-4) && clobber(x)
// result: (STM2 [i-4] {s} p w0 w1 mem)
@ -18090,9 +18465,6 @@ func rewriteValueS390X_OpS390XMOVWstore_0(v *Value) bool {
v.AddArg(mem)
return true
}
return false
}
func rewriteValueS390X_OpS390XMOVWstore_10(v *Value) bool {
// match: (MOVWstore [i] {s} p w2 x:(STM2 [i-8] {s} p w0 w1 mem))
// cond: x.Uses == 1 && is20Bit(i-8) && clobber(x)
// result: (STM3 [i-8] {s} p w0 w1 w2 mem)