mirror of
https://github.com/golang/go
synced 2024-10-06 08:00:07 +00:00
cmd/compile: fold double negate on arm64
Fixes #48467 Change-Id: I52305dbf561ee3eee6c1f053e555a3a6ec1ab892 Reviewed-on: https://go-review.googlesource.com/c/go/+/350910 Trust: Keith Randall <khr@golang.org> Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
parent
83b36ffb10
commit
315dbd10c9
|
@ -1363,6 +1363,7 @@
|
|||
(XOR x (MVN y)) => (EON x y)
|
||||
(OR x (MVN y)) => (ORN x y)
|
||||
(MVN (XOR x y)) => (EON x y)
|
||||
(NEG (NEG x)) => x
|
||||
|
||||
(CSEL [cc] (MOVDconst [-1]) (MOVDconst [0]) flag) => (CSETM [cc] flag)
|
||||
(CSEL [cc] (MOVDconst [0]) (MOVDconst [-1]) flag) => (CSETM [arm64Negate(cc)] flag)
|
||||
|
|
|
@ -15691,6 +15691,16 @@ func rewriteValueARM64_OpARM64NEG(v *Value) bool {
|
|||
v.AddArg2(x, y)
|
||||
return true
|
||||
}
|
||||
// match: (NEG (NEG x))
|
||||
// result: x
|
||||
for {
|
||||
if v_0.Op != OpARM64NEG {
|
||||
break
|
||||
}
|
||||
x := v_0.Args[0]
|
||||
v.copyOf(x)
|
||||
return true
|
||||
}
|
||||
// match: (NEG (MOVDconst [c]))
|
||||
// result: (MOVDconst [-c])
|
||||
for {
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
package codegen
|
||||
|
||||
import "math/bits"
|
||||
|
||||
/************************************
|
||||
* 64-bit instructions
|
||||
************************************/
|
||||
|
@ -355,3 +357,9 @@ func issue44228b(a []int32, i int) bool {
|
|||
// amd64: "BTL", -"SHL"
|
||||
return a[i>>5]&(1<<(i&31)) != 0
|
||||
}
|
||||
|
||||
func issue48467(x, y uint64) uint64 {
|
||||
// arm64: -"NEG"
|
||||
d, borrow := bits.Sub64(x, y, 0)
|
||||
return x - d&(-borrow)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue