diff options
author | Cherry Zhang <cherryyz@google.com> | 2021-01-29 13:46:34 -0500 |
---|---|---|
committer | Cherry Zhang <cherryyz@google.com> | 2021-02-03 22:44:53 +0000 |
commit | 401d7e5a242f1007c2637a25111a6fa985728c08 (patch) | |
tree | b2fdc485e38b26ed8e83386ba8467f363cf53ae6 /src/cmd/compile/internal/ssa/rewriteAMD64.go | |
parent | bfc7418e6d3a505fe348718fd113473c9d92b135 (diff) | |
download | go-401d7e5a242f1007c2637a25111a6fa985728c08.tar.gz go-401d7e5a242f1007c2637a25111a6fa985728c08.zip |
[dev.regabi] cmd/compile: reserve X15 as zero register on AMD64
In ABIInternal, reserve X15 as constant zero, and use it to zero
memory. (Maybe there can be more use of it?)
The register is zeroed when transition to ABIInternal from ABI0.
Caveat: using X15 generates longer instructions than using X0.
Maybe we want to use X0?
Change-Id: I12d5ee92a01fc0b59dad4e5ab023ac71bc2a8b7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/288093
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/rewriteAMD64.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/rewriteAMD64.go | 96 |
1 files changed, 41 insertions, 55 deletions
diff --git a/src/cmd/compile/internal/ssa/rewriteAMD64.go b/src/cmd/compile/internal/ssa/rewriteAMD64.go index db2dc7a004..6087874fa9 100644 --- a/src/cmd/compile/internal/ssa/rewriteAMD64.go +++ b/src/cmd/compile/internal/ssa/rewriteAMD64.go @@ -14226,7 +14226,7 @@ func rewriteValueAMD64_OpAMD64MOVQstoreconst(v *Value) bool { } // match: (MOVQstoreconst [c] {s} p x:(MOVQstoreconst [c2] {s} p mem)) // cond: config.useSSE && x.Uses == 1 && c2.Off() + 8 == c.Off() && c.Val() == 0 && c2.Val() == 0 && clobber(x) - // result: (MOVOstore [c2.Off32()] {s} p (MOVOconst [0]) mem) + // result: (MOVOstorezero [c2.Off32()] {s} p mem) for { c := auxIntToValAndOff(v.AuxInt) s := auxToSym(v.Aux) @@ -14243,12 +14243,10 @@ func rewriteValueAMD64_OpAMD64MOVQstoreconst(v *Value) bool { if p != x.Args[0] || !(config.useSSE && x.Uses == 1 && c2.Off()+8 == c.Off() && c.Val() == 0 && c2.Val() == 0 && clobber(x)) { break } - v.reset(OpAMD64MOVOstore) + v.reset(OpAMD64MOVOstorezero) v.AuxInt = int32ToAuxInt(c2.Off32()) v.Aux = symToAux(s) - v0 := b.NewValue0(x.Pos, OpAMD64MOVOconst, types.TypeInt128) - v0.AuxInt = int128ToAuxInt(0) - v.AddArg3(p, v0, mem) + v.AddArg2(p, mem) return true } // match: (MOVQstoreconst [sc] {sym1} (LEAL [off] {sym2} ptr) mem) @@ -34163,7 +34161,7 @@ func rewriteValueAMD64_OpZero(v *Value) bool { } // match: (Zero [s] destptr mem) // cond: s%16 != 0 && s > 16 && s%16 > 8 && config.useSSE - // result: (Zero [s-s%16] (OffPtr <destptr.Type> destptr [s%16]) (MOVOstore destptr (MOVOconst [0]) mem)) + // result: (Zero [s-s%16] (OffPtr <destptr.Type> destptr [s%16]) (MOVOstorezero destptr mem)) for { s := auxIntToInt64(v.AuxInt) destptr := v_0 @@ -34176,10 +34174,8 @@ func rewriteValueAMD64_OpZero(v *Value) bool { v0 := b.NewValue0(v.Pos, OpOffPtr, destptr.Type) v0.AuxInt = int64ToAuxInt(s % 16) v0.AddArg(destptr) - v1 := b.NewValue0(v.Pos, OpAMD64MOVOstore, types.TypeMem) - v2 := b.NewValue0(v.Pos, OpAMD64MOVOconst, types.TypeInt128) - v2.AuxInt = int128ToAuxInt(0) - v1.AddArg3(destptr, v2, mem) + v1 := b.NewValue0(v.Pos, OpAMD64MOVOstorezero, types.TypeMem) + v1.AddArg2(destptr, mem) v.AddArg2(v0, v1) return true } @@ -34206,7 +34202,7 @@ func rewriteValueAMD64_OpZero(v *Value) bool { } // match: (Zero [16] destptr mem) // cond: config.useSSE - // result: (MOVOstore destptr (MOVOconst [0]) mem) + // result: (MOVOstorezero destptr mem) for { if auxIntToInt64(v.AuxInt) != 16 { break @@ -34216,15 +34212,13 @@ func rewriteValueAMD64_OpZero(v *Value) bool { if !(config.useSSE) { break } - v.reset(OpAMD64MOVOstore) - v0 := b.NewValue0(v.Pos, OpAMD64MOVOconst, types.TypeInt128) - v0.AuxInt = int128ToAuxInt(0) - v.AddArg3(destptr, v0, mem) + v.reset(OpAMD64MOVOstorezero) + v.AddArg2(destptr, mem) return true } // match: (Zero [32] destptr mem) // cond: config.useSSE - // result: (MOVOstore (OffPtr <destptr.Type> destptr [16]) (MOVOconst [0]) (MOVOstore destptr (MOVOconst [0]) mem)) + // result: (MOVOstorezero (OffPtr <destptr.Type> destptr [16]) (MOVOstorezero destptr mem)) for { if auxIntToInt64(v.AuxInt) != 32 { break @@ -34234,20 +34228,18 @@ func rewriteValueAMD64_OpZero(v *Value) bool { if !(config.useSSE) { break } - v.reset(OpAMD64MOVOstore) + v.reset(OpAMD64MOVOstorezero) v0 := b.NewValue0(v.Pos, OpOffPtr, destptr.Type) v0.AuxInt = int64ToAuxInt(16) v0.AddArg(destptr) - v1 := b.NewValue0(v.Pos, OpAMD64MOVOconst, types.TypeInt128) - v1.AuxInt = int128ToAuxInt(0) - v2 := b.NewValue0(v.Pos, OpAMD64MOVOstore, types.TypeMem) - v2.AddArg3(destptr, v1, mem) - v.AddArg3(v0, v1, v2) + v1 := b.NewValue0(v.Pos, OpAMD64MOVOstorezero, types.TypeMem) + v1.AddArg2(destptr, mem) + v.AddArg2(v0, v1) return true } // match: (Zero [48] destptr mem) // cond: config.useSSE - // result: (MOVOstore (OffPtr <destptr.Type> destptr [32]) (MOVOconst [0]) (MOVOstore (OffPtr <destptr.Type> destptr [16]) (MOVOconst [0]) (MOVOstore destptr (MOVOconst [0]) mem))) + // result: (MOVOstorezero (OffPtr <destptr.Type> destptr [32]) (MOVOstorezero (OffPtr <destptr.Type> destptr [16]) (MOVOstorezero destptr mem))) for { if auxIntToInt64(v.AuxInt) != 48 { break @@ -34257,25 +34249,23 @@ func rewriteValueAMD64_OpZero(v *Value) bool { if !(config.useSSE) { break } - v.reset(OpAMD64MOVOstore) + v.reset(OpAMD64MOVOstorezero) v0 := b.NewValue0(v.Pos, OpOffPtr, destptr.Type) v0.AuxInt = int64ToAuxInt(32) v0.AddArg(destptr) - v1 := b.NewValue0(v.Pos, OpAMD64MOVOconst, types.TypeInt128) - v1.AuxInt = int128ToAuxInt(0) - v2 := b.NewValue0(v.Pos, OpAMD64MOVOstore, types.TypeMem) - v3 := b.NewValue0(v.Pos, OpOffPtr, destptr.Type) - v3.AuxInt = int64ToAuxInt(16) - v3.AddArg(destptr) - v4 := b.NewValue0(v.Pos, OpAMD64MOVOstore, types.TypeMem) - v4.AddArg3(destptr, v1, mem) - v2.AddArg3(v3, v1, v4) - v.AddArg3(v0, v1, v2) + v1 := b.NewValue0(v.Pos, OpAMD64MOVOstorezero, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpOffPtr, destptr.Type) + v2.AuxInt = int64ToAuxInt(16) + v2.AddArg(destptr) + v3 := b.NewValue0(v.Pos, OpAMD64MOVOstorezero, types.TypeMem) + v3.AddArg2(destptr, mem) + v1.AddArg2(v2, v3) + v.AddArg2(v0, v1) return true } // match: (Zero [64] destptr mem) // cond: config.useSSE - // result: (MOVOstore (OffPtr <destptr.Type> destptr [48]) (MOVOconst [0]) (MOVOstore (OffPtr <destptr.Type> destptr [32]) (MOVOconst [0]) (MOVOstore (OffPtr <destptr.Type> destptr [16]) (MOVOconst [0]) (MOVOstore destptr (MOVOconst [0]) mem)))) + // result: (MOVOstorezero (OffPtr <destptr.Type> destptr [48]) (MOVOstorezero (OffPtr <destptr.Type> destptr [32]) (MOVOstorezero (OffPtr <destptr.Type> destptr [16]) (MOVOstorezero destptr mem)))) for { if auxIntToInt64(v.AuxInt) != 64 { break @@ -34285,30 +34275,28 @@ func rewriteValueAMD64_OpZero(v *Value) bool { if !(config.useSSE) { break } - v.reset(OpAMD64MOVOstore) + v.reset(OpAMD64MOVOstorezero) v0 := b.NewValue0(v.Pos, OpOffPtr, destptr.Type) v0.AuxInt = int64ToAuxInt(48) v0.AddArg(destptr) - v1 := b.NewValue0(v.Pos, OpAMD64MOVOconst, types.TypeInt128) - v1.AuxInt = int128ToAuxInt(0) - v2 := b.NewValue0(v.Pos, OpAMD64MOVOstore, types.TypeMem) - v3 := b.NewValue0(v.Pos, OpOffPtr, destptr.Type) - v3.AuxInt = int64ToAuxInt(32) - v3.AddArg(destptr) - v4 := b.NewValue0(v.Pos, OpAMD64MOVOstore, types.TypeMem) - v5 := b.NewValue0(v.Pos, OpOffPtr, destptr.Type) - v5.AuxInt = int64ToAuxInt(16) - v5.AddArg(destptr) - v6 := b.NewValue0(v.Pos, OpAMD64MOVOstore, types.TypeMem) - v6.AddArg3(destptr, v1, mem) - v4.AddArg3(v5, v1, v6) - v2.AddArg3(v3, v1, v4) - v.AddArg3(v0, v1, v2) + v1 := b.NewValue0(v.Pos, OpAMD64MOVOstorezero, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpOffPtr, destptr.Type) + v2.AuxInt = int64ToAuxInt(32) + v2.AddArg(destptr) + v3 := b.NewValue0(v.Pos, OpAMD64MOVOstorezero, types.TypeMem) + v4 := b.NewValue0(v.Pos, OpOffPtr, destptr.Type) + v4.AuxInt = int64ToAuxInt(16) + v4.AddArg(destptr) + v5 := b.NewValue0(v.Pos, OpAMD64MOVOstorezero, types.TypeMem) + v5.AddArg2(destptr, mem) + v3.AddArg2(v4, v5) + v1.AddArg2(v2, v3) + v.AddArg2(v0, v1) return true } // match: (Zero [s] destptr mem) // cond: s > 64 && s <= 1024 && s%16 == 0 && !config.noDuffDevice - // result: (DUFFZERO [s] destptr (MOVOconst [0]) mem) + // result: (DUFFZERO [s] destptr mem) for { s := auxIntToInt64(v.AuxInt) destptr := v_0 @@ -34318,9 +34306,7 @@ func rewriteValueAMD64_OpZero(v *Value) bool { } v.reset(OpAMD64DUFFZERO) v.AuxInt = int64ToAuxInt(s) - v0 := b.NewValue0(v.Pos, OpAMD64MOVOconst, types.TypeInt128) - v0.AuxInt = int128ToAuxInt(0) - v.AddArg3(destptr, v0, mem) + v.AddArg2(destptr, mem) return true } // match: (Zero [s] destptr mem) |