From 331c187b173e5128ed24a0670c3e5010498c1954 Mon Sep 17 00:00:00 2001 From: Michael Munday Date: Tue, 27 Mar 2018 11:52:56 +0100 Subject: [PATCH] cmd/compile: simplify Neg lowering on s390x No need to sign extend input to Neg8 and Neg16. Change-Id: I7896c83c9cdf84a34098582351a4aabf61cd6fdd Reviewed-on: https://go-review.googlesource.com/102675 Run-TryBot: Michael Munday TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/cmd/compile/internal/ssa/gen/S390X.rules | 6 ++---- src/cmd/compile/internal/ssa/rewriteS390X.go | 20 ++++---------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/cmd/compile/internal/ssa/gen/S390X.rules b/src/cmd/compile/internal/ssa/gen/S390X.rules index 280e85004c..6eba1e0264 100644 --- a/src/cmd/compile/internal/ssa/gen/S390X.rules +++ b/src/cmd/compile/internal/ssa/gen/S390X.rules @@ -58,10 +58,8 @@ (Xor64 x y) -> (XOR x y) (Xor(32|16|8) x y) -> (XORW x y) -(Neg64 x) -> (NEG x) -(Neg32 x) -> (NEGW x) -(Neg16 x) -> (NEGW (MOVHreg x)) -(Neg8 x) -> (NEGW (MOVBreg x)) +(Neg64 x) -> (NEG x) +(Neg(32|16|8) x) -> (NEGW x) (Neg32F x) -> (FNEGS x) (Neg64F x) -> (FNEG x) diff --git a/src/cmd/compile/internal/ssa/rewriteS390X.go b/src/cmd/compile/internal/ssa/rewriteS390X.go index 480512aaaa..d3e15ac037 100644 --- a/src/cmd/compile/internal/ssa/rewriteS390X.go +++ b/src/cmd/compile/internal/ssa/rewriteS390X.go @@ -4564,19 +4564,13 @@ func rewriteValueS390X_OpMul8_0(v *Value) bool { } } func rewriteValueS390X_OpNeg16_0(v *Value) bool { - b := v.Block - _ = b - typ := &b.Func.Config.Types - _ = typ // match: (Neg16 x) // cond: - // result: (NEGW (MOVHreg x)) + // result: (NEGW x) for { x := v.Args[0] v.reset(OpS390XNEGW) - v0 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) - v0.AddArg(x) - v.AddArg(v0) + v.AddArg(x) return true } } @@ -4625,19 +4619,13 @@ func rewriteValueS390X_OpNeg64F_0(v *Value) bool { } } func rewriteValueS390X_OpNeg8_0(v *Value) bool { - b := v.Block - _ = b - typ := &b.Func.Config.Types - _ = typ // match: (Neg8 x) // cond: - // result: (NEGW (MOVBreg x)) + // result: (NEGW x) for { x := v.Args[0] v.reset(OpS390XNEGW) - v0 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) - v0.AddArg(x) - v.AddArg(v0) + v.AddArg(x) return true } }