mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: add store to load forwarding rules on riscv64
Adds the equivalent integer variants of the floating point rules added in CL 599235. Change-Id: Ibe03c26383059821d99cea2337799e6416b4c581 Reviewed-on: https://go-review.googlesource.com/c/go/+/700175 Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Julian Zhu <jz531210@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
80038586ed
commit
4373754bc9
2 changed files with 135 additions and 0 deletions
|
|
@ -716,6 +716,8 @@
|
||||||
(MOVWUreg <t> x:(MOVWload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (MOVWUload <t> [off] {sym} ptr mem)
|
(MOVWUreg <t> x:(MOVWload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (MOVWUload <t> [off] {sym} ptr mem)
|
||||||
|
|
||||||
// Replace load from same location as preceding store with copy.
|
// Replace load from same location as preceding store with copy.
|
||||||
|
(MOV(D|W|H|B)load [off] {sym} ptr1 (MOV(D|W|H|B)store [off] {sym} ptr2 x _)) && isSamePtr(ptr1, ptr2) => (MOV(D|W|H|B)reg x)
|
||||||
|
(MOV(W|H|B)Uload [off] {sym} ptr1 (MOV(W|H|B)store [off] {sym} ptr2 x _)) && isSamePtr(ptr1, ptr2) => (MOV(W|H|B)Ureg x)
|
||||||
(MOVDload [off] {sym} ptr1 (FMOVDstore [off] {sym} ptr2 x _)) && isSamePtr(ptr1, ptr2) => (FMVXD x)
|
(MOVDload [off] {sym} ptr1 (FMOVDstore [off] {sym} ptr2 x _)) && isSamePtr(ptr1, ptr2) => (FMVXD x)
|
||||||
(FMOVDload [off] {sym} ptr1 (MOVDstore [off] {sym} ptr2 x _)) && isSamePtr(ptr1, ptr2) => (FMVDX x)
|
(FMOVDload [off] {sym} ptr1 (MOVDstore [off] {sym} ptr2 x _)) && isSamePtr(ptr1, ptr2) => (FMVDX x)
|
||||||
(MOVWload [off] {sym} ptr1 (FMOVWstore [off] {sym} ptr2 x _)) && isSamePtr(ptr1, ptr2) => (FMVXS x)
|
(MOVWload [off] {sym} ptr1 (FMOVWstore [off] {sym} ptr2 x _)) && isSamePtr(ptr1, ptr2) => (FMVXS x)
|
||||||
|
|
|
||||||
|
|
@ -4740,6 +4740,25 @@ func rewriteValueRISCV64_OpRISCV64MOVBUload(v *Value) bool {
|
||||||
v.AddArg2(base, mem)
|
v.AddArg2(base, mem)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
// match: (MOVBUload [off] {sym} ptr1 (MOVBstore [off] {sym} ptr2 x _))
|
||||||
|
// cond: isSamePtr(ptr1, ptr2)
|
||||||
|
// result: (MOVBUreg x)
|
||||||
|
for {
|
||||||
|
off := auxIntToInt32(v.AuxInt)
|
||||||
|
sym := auxToSym(v.Aux)
|
||||||
|
ptr1 := v_0
|
||||||
|
if v_1.Op != OpRISCV64MOVBstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
x := v_1.Args[1]
|
||||||
|
ptr2 := v_1.Args[0]
|
||||||
|
if !(isSamePtr(ptr1, ptr2)) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
v.reset(OpRISCV64MOVBUreg)
|
||||||
|
v.AddArg(x)
|
||||||
|
return true
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
func rewriteValueRISCV64_OpRISCV64MOVBUreg(v *Value) bool {
|
func rewriteValueRISCV64_OpRISCV64MOVBUreg(v *Value) bool {
|
||||||
|
|
@ -5049,6 +5068,25 @@ func rewriteValueRISCV64_OpRISCV64MOVBload(v *Value) bool {
|
||||||
v.AddArg2(base, mem)
|
v.AddArg2(base, mem)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
// match: (MOVBload [off] {sym} ptr1 (MOVBstore [off] {sym} ptr2 x _))
|
||||||
|
// cond: isSamePtr(ptr1, ptr2)
|
||||||
|
// result: (MOVBreg x)
|
||||||
|
for {
|
||||||
|
off := auxIntToInt32(v.AuxInt)
|
||||||
|
sym := auxToSym(v.Aux)
|
||||||
|
ptr1 := v_0
|
||||||
|
if v_1.Op != OpRISCV64MOVBstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
x := v_1.Args[1]
|
||||||
|
ptr2 := v_1.Args[0]
|
||||||
|
if !(isSamePtr(ptr1, ptr2)) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
v.reset(OpRISCV64MOVBreg)
|
||||||
|
v.AddArg(x)
|
||||||
|
return true
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
func rewriteValueRISCV64_OpRISCV64MOVBreg(v *Value) bool {
|
func rewriteValueRISCV64_OpRISCV64MOVBreg(v *Value) bool {
|
||||||
|
|
@ -5397,6 +5435,25 @@ func rewriteValueRISCV64_OpRISCV64MOVDload(v *Value) bool {
|
||||||
v.AddArg2(base, mem)
|
v.AddArg2(base, mem)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
// match: (MOVDload [off] {sym} ptr1 (MOVDstore [off] {sym} ptr2 x _))
|
||||||
|
// cond: isSamePtr(ptr1, ptr2)
|
||||||
|
// result: (MOVDreg x)
|
||||||
|
for {
|
||||||
|
off := auxIntToInt32(v.AuxInt)
|
||||||
|
sym := auxToSym(v.Aux)
|
||||||
|
ptr1 := v_0
|
||||||
|
if v_1.Op != OpRISCV64MOVDstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
x := v_1.Args[1]
|
||||||
|
ptr2 := v_1.Args[0]
|
||||||
|
if !(isSamePtr(ptr1, ptr2)) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
v.reset(OpRISCV64MOVDreg)
|
||||||
|
v.AddArg(x)
|
||||||
|
return true
|
||||||
|
}
|
||||||
// match: (MOVDload [off] {sym} ptr1 (FMOVDstore [off] {sym} ptr2 x _))
|
// match: (MOVDload [off] {sym} ptr1 (FMOVDstore [off] {sym} ptr2 x _))
|
||||||
// cond: isSamePtr(ptr1, ptr2)
|
// cond: isSamePtr(ptr1, ptr2)
|
||||||
// result: (FMVXD x)
|
// result: (FMVXD x)
|
||||||
|
|
@ -5616,6 +5673,25 @@ func rewriteValueRISCV64_OpRISCV64MOVHUload(v *Value) bool {
|
||||||
v.AddArg2(base, mem)
|
v.AddArg2(base, mem)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
// match: (MOVHUload [off] {sym} ptr1 (MOVHstore [off] {sym} ptr2 x _))
|
||||||
|
// cond: isSamePtr(ptr1, ptr2)
|
||||||
|
// result: (MOVHUreg x)
|
||||||
|
for {
|
||||||
|
off := auxIntToInt32(v.AuxInt)
|
||||||
|
sym := auxToSym(v.Aux)
|
||||||
|
ptr1 := v_0
|
||||||
|
if v_1.Op != OpRISCV64MOVHstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
x := v_1.Args[1]
|
||||||
|
ptr2 := v_1.Args[0]
|
||||||
|
if !(isSamePtr(ptr1, ptr2)) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
v.reset(OpRISCV64MOVHUreg)
|
||||||
|
v.AddArg(x)
|
||||||
|
return true
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
func rewriteValueRISCV64_OpRISCV64MOVHUreg(v *Value) bool {
|
func rewriteValueRISCV64_OpRISCV64MOVHUreg(v *Value) bool {
|
||||||
|
|
@ -5782,6 +5858,25 @@ func rewriteValueRISCV64_OpRISCV64MOVHload(v *Value) bool {
|
||||||
v.AddArg2(base, mem)
|
v.AddArg2(base, mem)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
// match: (MOVHload [off] {sym} ptr1 (MOVHstore [off] {sym} ptr2 x _))
|
||||||
|
// cond: isSamePtr(ptr1, ptr2)
|
||||||
|
// result: (MOVHreg x)
|
||||||
|
for {
|
||||||
|
off := auxIntToInt32(v.AuxInt)
|
||||||
|
sym := auxToSym(v.Aux)
|
||||||
|
ptr1 := v_0
|
||||||
|
if v_1.Op != OpRISCV64MOVHstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
x := v_1.Args[1]
|
||||||
|
ptr2 := v_1.Args[0]
|
||||||
|
if !(isSamePtr(ptr1, ptr2)) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
v.reset(OpRISCV64MOVHreg)
|
||||||
|
v.AddArg(x)
|
||||||
|
return true
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
func rewriteValueRISCV64_OpRISCV64MOVHreg(v *Value) bool {
|
func rewriteValueRISCV64_OpRISCV64MOVHreg(v *Value) bool {
|
||||||
|
|
@ -6141,6 +6236,25 @@ func rewriteValueRISCV64_OpRISCV64MOVWUload(v *Value) bool {
|
||||||
v.AddArg2(base, mem)
|
v.AddArg2(base, mem)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
// match: (MOVWUload [off] {sym} ptr1 (MOVWstore [off] {sym} ptr2 x _))
|
||||||
|
// cond: isSamePtr(ptr1, ptr2)
|
||||||
|
// result: (MOVWUreg x)
|
||||||
|
for {
|
||||||
|
off := auxIntToInt32(v.AuxInt)
|
||||||
|
sym := auxToSym(v.Aux)
|
||||||
|
ptr1 := v_0
|
||||||
|
if v_1.Op != OpRISCV64MOVWstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
x := v_1.Args[1]
|
||||||
|
ptr2 := v_1.Args[0]
|
||||||
|
if !(isSamePtr(ptr1, ptr2)) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
v.reset(OpRISCV64MOVWUreg)
|
||||||
|
v.AddArg(x)
|
||||||
|
return true
|
||||||
|
}
|
||||||
// match: (MOVWUload [off] {sym} ptr1 (FMOVWstore [off] {sym} ptr2 x _))
|
// match: (MOVWUload [off] {sym} ptr1 (FMOVWstore [off] {sym} ptr2 x _))
|
||||||
// cond: isSamePtr(ptr1, ptr2)
|
// cond: isSamePtr(ptr1, ptr2)
|
||||||
// result: (MOVWUreg (FMVXS x))
|
// result: (MOVWUreg (FMVXS x))
|
||||||
|
|
@ -6352,6 +6466,25 @@ func rewriteValueRISCV64_OpRISCV64MOVWload(v *Value) bool {
|
||||||
v.AddArg2(base, mem)
|
v.AddArg2(base, mem)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
// match: (MOVWload [off] {sym} ptr1 (MOVWstore [off] {sym} ptr2 x _))
|
||||||
|
// cond: isSamePtr(ptr1, ptr2)
|
||||||
|
// result: (MOVWreg x)
|
||||||
|
for {
|
||||||
|
off := auxIntToInt32(v.AuxInt)
|
||||||
|
sym := auxToSym(v.Aux)
|
||||||
|
ptr1 := v_0
|
||||||
|
if v_1.Op != OpRISCV64MOVWstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
x := v_1.Args[1]
|
||||||
|
ptr2 := v_1.Args[0]
|
||||||
|
if !(isSamePtr(ptr1, ptr2)) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
v.reset(OpRISCV64MOVWreg)
|
||||||
|
v.AddArg(x)
|
||||||
|
return true
|
||||||
|
}
|
||||||
// match: (MOVWload [off] {sym} ptr1 (FMOVWstore [off] {sym} ptr2 x _))
|
// match: (MOVWload [off] {sym} ptr1 (FMOVWstore [off] {sym} ptr2 x _))
|
||||||
// cond: isSamePtr(ptr1, ptr2)
|
// cond: isSamePtr(ptr1, ptr2)
|
||||||
// result: (FMVXS x)
|
// result: (FMVXS x)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue