From 315dbd10c90db3b41af2c975a5fbfa2ec7615c1b Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Sun, 19 Sep 2021 09:23:37 -0700 Subject: 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 Trust: Josh Bleecher Snyder Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Josh Bleecher Snyder --- test/codegen/bits.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/codegen') diff --git a/test/codegen/bits.go b/test/codegen/bits.go index 8117a62307..8e973d5726 100644 --- a/test/codegen/bits.go +++ b/test/codegen/bits.go @@ -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) +} -- cgit v1.3