mirror of https://github.com/golang/go.git
cmd/compile: fold negation into addition/subtraction on s390x
Fold negation into addition/subtraction and avoid double negation. file before after Δ % addr2line 3909260 3909204 -56 -0.001% asm 6714513 6714505 -8 -0.000% buildid 3680344 3679504 -840 -0.023% cgo 6219857 6219521 -336 -0.005% compile 29527941 29528037 +96 +0.000% cover 6869451 6868731 -720 -0.010% dist 4498817 4498769 -48 -0.001% doc 10483319 10481719 -1600 -0.015% fix 4356204 4355932 -272 -0.006% link 9080951 9080383 -568 -0.006% nm 3899682 3833674 -66008 -1.693% objdump 6347837 6347605 -232 -0.004% pack 3103750 3103454 -296 -0.010% pprof 18849998 18849478 -520 -0.003% test2json 3619671 3619511 -160 -0.004% trace 17164007 17161463 -2544 -0.015% vet 10465861 10465173 -688 -0.007% total 167058409 166983609 -74800 -0.045% Change-Id: I1b8cf3939b433e1765682196b8fc1aa07d37f895 Reviewed-on: https://go-review.googlesource.com/c/go/+/673476 Auto-Submit: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
parent
edcde86990
commit
7589e96042
|
|
@ -1188,6 +1188,8 @@
|
||||||
// TODO: more of this
|
// TODO: more of this
|
||||||
(ADD x (NEG y)) => (SUB x y)
|
(ADD x (NEG y)) => (SUB x y)
|
||||||
(ADDW x (NEGW y)) => (SUBW x y)
|
(ADDW x (NEGW y)) => (SUBW x y)
|
||||||
|
(SUB x (NEG y)) => (ADD x y)
|
||||||
|
(SUBW x (NEGW y)) => (ADDW x y)
|
||||||
(SUB x x) => (MOVDconst [0])
|
(SUB x x) => (MOVDconst [0])
|
||||||
(SUBW x x) => (MOVDconst [0])
|
(SUBW x x) => (MOVDconst [0])
|
||||||
(AND x x) => x
|
(AND x x) => x
|
||||||
|
|
@ -1196,6 +1198,7 @@
|
||||||
(ORW x x) => x
|
(ORW x x) => x
|
||||||
(XOR x x) => (MOVDconst [0])
|
(XOR x x) => (MOVDconst [0])
|
||||||
(XORW x x) => (MOVDconst [0])
|
(XORW x x) => (MOVDconst [0])
|
||||||
|
(NEG (NEG x)) => x
|
||||||
(NEG (ADDconst [c] (NEG x))) && c != -(1<<31) => (ADDconst [-c] x)
|
(NEG (ADDconst [c] (NEG x))) && c != -(1<<31) => (ADDconst [-c] x)
|
||||||
(MOVBZreg (ANDWconst [m] x)) => (MOVWZreg (ANDWconst <typ.UInt32> [int32( uint8(m))] x))
|
(MOVBZreg (ANDWconst [m] x)) => (MOVWZreg (ANDWconst <typ.UInt32> [int32( uint8(m))] x))
|
||||||
(MOVHZreg (ANDWconst [m] x)) => (MOVWZreg (ANDWconst <typ.UInt32> [int32(uint16(m))] x))
|
(MOVHZreg (ANDWconst [m] x)) => (MOVWZreg (ANDWconst <typ.UInt32> [int32(uint16(m))] x))
|
||||||
|
|
|
||||||
|
|
@ -11292,6 +11292,16 @@ func rewriteValueS390X_OpS390XNEG(v *Value) bool {
|
||||||
v.AuxInt = int64ToAuxInt(-c)
|
v.AuxInt = int64ToAuxInt(-c)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
// match: (NEG (NEG x))
|
||||||
|
// result: x
|
||||||
|
for {
|
||||||
|
if v_0.Op != OpS390XNEG {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
x := v_0.Args[0]
|
||||||
|
v.copyOf(x)
|
||||||
|
return true
|
||||||
|
}
|
||||||
// match: (NEG (ADDconst [c] (NEG x)))
|
// match: (NEG (ADDconst [c] (NEG x)))
|
||||||
// cond: c != -(1<<31)
|
// cond: c != -(1<<31)
|
||||||
// result: (ADDconst [-c] x)
|
// result: (ADDconst [-c] x)
|
||||||
|
|
@ -13326,6 +13336,18 @@ func rewriteValueS390X_OpS390XSUB(v *Value) bool {
|
||||||
v.AddArg(v0)
|
v.AddArg(v0)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
// match: (SUB x (NEG y))
|
||||||
|
// result: (ADD x y)
|
||||||
|
for {
|
||||||
|
x := v_0
|
||||||
|
if v_1.Op != OpS390XNEG {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
y := v_1.Args[0]
|
||||||
|
v.reset(OpS390XADD)
|
||||||
|
v.AddArg2(x, y)
|
||||||
|
return true
|
||||||
|
}
|
||||||
// match: (SUB x x)
|
// match: (SUB x x)
|
||||||
// result: (MOVDconst [0])
|
// result: (MOVDconst [0])
|
||||||
for {
|
for {
|
||||||
|
|
@ -13467,6 +13489,18 @@ func rewriteValueS390X_OpS390XSUBW(v *Value) bool {
|
||||||
v.AddArg(v0)
|
v.AddArg(v0)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
// match: (SUBW x (NEGW y))
|
||||||
|
// result: (ADDW x y)
|
||||||
|
for {
|
||||||
|
x := v_0
|
||||||
|
if v_1.Op != OpS390XNEGW {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
y := v_1.Args[0]
|
||||||
|
v.reset(OpS390XADDW)
|
||||||
|
v.AddArg2(x, y)
|
||||||
|
return true
|
||||||
|
}
|
||||||
// match: (SUBW x x)
|
// match: (SUBW x x)
|
||||||
// result: (MOVDconst [0])
|
// result: (MOVDconst [0])
|
||||||
for {
|
for {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue