aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/rewritePPC64.go
diff options
context:
space:
mode:
authorLynn Boger <laboger@linux.vnet.ibm.com>2020-04-23 15:36:28 -0400
committerLynn Boger <laboger@linux.vnet.ibm.com>2020-04-29 14:45:56 +0000
commit56933fb83852837f169cb35a23815f23c799da87 (patch)
tree744d289f737b6880622cb088554778b197620cdc /src/cmd/compile/internal/ssa/rewritePPC64.go
parent07d9ea64abf9f98c525155f4f22776512d4d835d (diff)
downloadgo-56933fb83852837f169cb35a23815f23c799da87.tar.gz
go-56933fb83852837f169cb35a23815f23c799da87.zip
cmd/compile,cmd/internal/obj/ppc64: use mod instructions on power9
This updates the PPC64.rules file to use the MOD instructions that are available in power9. Prior to power9 this is done using a longer sequence with multiply and divide. Included in this change is removal of the REM* opcode variations that set the CC or OV bits since their settings are based on the DIV and are not appropriate for the REM. Change-Id: Iceed9ce33e128e1911c15592ee674276ce8ba3fa Reviewed-on: https://go-review.googlesource.com/c/go/+/229761 Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/rewritePPC64.go')
-rw-r--r--src/cmd/compile/internal/ssa/rewritePPC64.go72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/rewritePPC64.go b/src/cmd/compile/internal/ssa/rewritePPC64.go
index 13c188e78d..0b798c6a72 100644
--- a/src/cmd/compile/internal/ssa/rewritePPC64.go
+++ b/src/cmd/compile/internal/ssa/rewritePPC64.go
@@ -3231,10 +3231,27 @@ func rewriteValuePPC64_OpMod32(v *Value) bool {
b := v.Block
typ := &b.Func.Config.Types
// match: (Mod32 x y)
+ // cond: objabi.GOPPC64 >= 9
+ // result: (MODSW x y)
+ for {
+ x := v_0
+ y := v_1
+ if !(objabi.GOPPC64 >= 9) {
+ break
+ }
+ v.reset(OpPPC64MODSW)
+ v.AddArg2(x, y)
+ return true
+ }
+ // match: (Mod32 x y)
+ // cond: objabi.GOPPC64 <= 8
// result: (SUB x (MULLW y (DIVW x y)))
for {
x := v_0
y := v_1
+ if !(objabi.GOPPC64 <= 8) {
+ break
+ }
v.reset(OpPPC64SUB)
v0 := b.NewValue0(v.Pos, OpPPC64MULLW, typ.Int32)
v1 := b.NewValue0(v.Pos, OpPPC64DIVW, typ.Int32)
@@ -3243,6 +3260,7 @@ func rewriteValuePPC64_OpMod32(v *Value) bool {
v.AddArg2(x, v0)
return true
}
+ return false
}
func rewriteValuePPC64_OpMod32u(v *Value) bool {
v_1 := v.Args[1]
@@ -3250,10 +3268,27 @@ func rewriteValuePPC64_OpMod32u(v *Value) bool {
b := v.Block
typ := &b.Func.Config.Types
// match: (Mod32u x y)
+ // cond: objabi.GOPPC64 >= 9
+ // result: (MODUW x y)
+ for {
+ x := v_0
+ y := v_1
+ if !(objabi.GOPPC64 >= 9) {
+ break
+ }
+ v.reset(OpPPC64MODUW)
+ v.AddArg2(x, y)
+ return true
+ }
+ // match: (Mod32u x y)
+ // cond: objabi.GOPPC64 <= 8
// result: (SUB x (MULLW y (DIVWU x y)))
for {
x := v_0
y := v_1
+ if !(objabi.GOPPC64 <= 8) {
+ break
+ }
v.reset(OpPPC64SUB)
v0 := b.NewValue0(v.Pos, OpPPC64MULLW, typ.Int32)
v1 := b.NewValue0(v.Pos, OpPPC64DIVWU, typ.Int32)
@@ -3262,6 +3297,7 @@ func rewriteValuePPC64_OpMod32u(v *Value) bool {
v.AddArg2(x, v0)
return true
}
+ return false
}
func rewriteValuePPC64_OpMod64(v *Value) bool {
v_1 := v.Args[1]
@@ -3269,10 +3305,27 @@ func rewriteValuePPC64_OpMod64(v *Value) bool {
b := v.Block
typ := &b.Func.Config.Types
// match: (Mod64 x y)
+ // cond: objabi.GOPPC64 >=9
+ // result: (MODSD x y)
+ for {
+ x := v_0
+ y := v_1
+ if !(objabi.GOPPC64 >= 9) {
+ break
+ }
+ v.reset(OpPPC64MODSD)
+ v.AddArg2(x, y)
+ return true
+ }
+ // match: (Mod64 x y)
+ // cond: objabi.GOPPC64 <=8
// result: (SUB x (MULLD y (DIVD x y)))
for {
x := v_0
y := v_1
+ if !(objabi.GOPPC64 <= 8) {
+ break
+ }
v.reset(OpPPC64SUB)
v0 := b.NewValue0(v.Pos, OpPPC64MULLD, typ.Int64)
v1 := b.NewValue0(v.Pos, OpPPC64DIVD, typ.Int64)
@@ -3281,6 +3334,7 @@ func rewriteValuePPC64_OpMod64(v *Value) bool {
v.AddArg2(x, v0)
return true
}
+ return false
}
func rewriteValuePPC64_OpMod64u(v *Value) bool {
v_1 := v.Args[1]
@@ -3288,10 +3342,27 @@ func rewriteValuePPC64_OpMod64u(v *Value) bool {
b := v.Block
typ := &b.Func.Config.Types
// match: (Mod64u x y)
+ // cond: objabi.GOPPC64 >= 9
+ // result: (MODUD x y)
+ for {
+ x := v_0
+ y := v_1
+ if !(objabi.GOPPC64 >= 9) {
+ break
+ }
+ v.reset(OpPPC64MODUD)
+ v.AddArg2(x, y)
+ return true
+ }
+ // match: (Mod64u x y)
+ // cond: objabi.GOPPC64 <= 8
// result: (SUB x (MULLD y (DIVDU x y)))
for {
x := v_0
y := v_1
+ if !(objabi.GOPPC64 <= 8) {
+ break
+ }
v.reset(OpPPC64SUB)
v0 := b.NewValue0(v.Pos, OpPPC64MULLD, typ.Int64)
v1 := b.NewValue0(v.Pos, OpPPC64DIVDU, typ.Int64)
@@ -3300,6 +3371,7 @@ func rewriteValuePPC64_OpMod64u(v *Value) bool {
v.AddArg2(x, v0)
return true
}
+ return false
}
func rewriteValuePPC64_OpMod8(v *Value) bool {
v_1 := v.Args[1]