From 44053de36509f4634befbf7ad442b5debd0f0cdf Mon Sep 17 00:00:00 2001 From: Lynn Boger Date: Fri, 10 Feb 2017 15:40:44 -0500 Subject: [PATCH] cmd/compile: use reg moves for int <-> float conversions on ppc64x This makes a change in the SSA code generated for OpPPC64Xf2i64 and OpPPC64Xi2f64 to use register based instructions to convert between float and integer. This will require at least power8. Currently the conversion is done by storing to and loading from memory, which is more expensive. This improves some of the math functions: BenchmarkExp-128 74.1 66.8 -9.85% BenchmarkExpGo-128 87.4 66.3 -24.14% BenchmarkExp2-128 72.2 64.3 -10.94% BenchmarkExp2Go-128 74.3 65.9 -11.31% BenchmarkLgamma-128 51.0 39.7 -22.16% BenchmarkLog-128 42.9 40.6 -5.36% BenchmarkLogb-128 11.5 9.16 -20.35% BenchmarkLog1p-128 38.9 36.2 -6.94% BenchmarkSin-128 29.5 23.7 -19.66% BenchmarkTan-128 32.8 27.4 -16.46% Fixes #18922 Change-Id: I8e1cf14d3880d7cd720dc5188dd174cba1f7fef7 Reviewed-on: https://go-review.googlesource.com/36725 Reviewed-by: Carlos Eduardo Seo Reviewed-by: Keith Randall --- src/cmd/compile/internal/ppc64/prog.go | 2 ++ src/cmd/compile/internal/ppc64/ssa.go | 12 ++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/cmd/compile/internal/ppc64/prog.go b/src/cmd/compile/internal/ppc64/prog.go index dbcf68f256b..d26d09fce13 100644 --- a/src/cmd/compile/internal/ppc64/prog.go +++ b/src/cmd/compile/internal/ppc64/prog.go @@ -111,6 +111,8 @@ var progtable = [ppc64.ALAST & obj.AMask]gc.ProgInfo{ ppc64.AFMOVSX & obj.AMask: {Flags: gc.SizeF | gc.LeftRead | gc.RightWrite | gc.Move | gc.Conv}, ppc64.AFMOVSZ & obj.AMask: {Flags: gc.SizeF | gc.LeftRead | gc.RightWrite | gc.Move | gc.Conv}, ppc64.AFMOVD & obj.AMask: {Flags: gc.SizeD | gc.LeftRead | gc.RightWrite | gc.Move}, + ppc64.AMFVSRD & obj.AMask: {Flags: gc.SizeD | gc.LeftRead | gc.RightWrite | gc.Move}, + ppc64.AMTVSRD & obj.AMask: {Flags: gc.SizeD | gc.LeftRead | gc.RightWrite | gc.Move}, // Jumps ppc64.ABR & obj.AMask: {Flags: gc.Jump | gc.Break}, diff --git a/src/cmd/compile/internal/ppc64/ssa.go b/src/cmd/compile/internal/ppc64/ssa.go index 2c0cbad06f1..762a118084d 100644 --- a/src/cmd/compile/internal/ppc64/ssa.go +++ b/src/cmd/compile/internal/ppc64/ssa.go @@ -177,27 +177,23 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { { x := v.Args[0].Reg() y := v.Reg() - p := gc.Prog(ppc64.AFMOVD) + + p := gc.Prog(ppc64.AMFVSRD) p.From.Type = obj.TYPE_REG p.From.Reg = x - s.AddrScratch(&p.To) - p = gc.Prog(ppc64.AMOVD) p.To.Type = obj.TYPE_REG p.To.Reg = y - s.AddrScratch(&p.From) } case ssa.OpPPC64Xi2f64: { x := v.Args[0].Reg() y := v.Reg() - p := gc.Prog(ppc64.AMOVD) + + p := gc.Prog(ppc64.AMTVSRD) p.From.Type = obj.TYPE_REG p.From.Reg = x - s.AddrScratch(&p.To) - p = gc.Prog(ppc64.AFMOVD) p.To.Type = obj.TYPE_REG p.To.Reg = y - s.AddrScratch(&p.From) } case ssa.OpPPC64LoweredGetClosurePtr: