aboutsummaryrefslogtreecommitdiff
path: root/test/codegen
diff options
context:
space:
mode:
authorCh1n-ch1nless <aleksandrov.oa.work@gmail.com>2025-08-21 20:09:59 +0300
committerGopher Robot <gobot@golang.org>2026-02-12 09:27:24 -0800
commitfbe55325ddce51a7fc099e1efb0d326e7a2e1ed8 (patch)
tree6cf63bd251bfb2c6b6eade4938da86c4c2b317ef /test/codegen
parent20bc1949722c1fd66de5d568f1422845332d18f3 (diff)
downloadgo-fbe55325ddce51a7fc099e1efb0d326e7a2e1ed8.tar.xz
cmd/compile: replace conditions to CCMP instructions on ARM64
This change introduces a new SSA pass that converts conditionals with logical AND into CMP/CCMP instruction sequences on ARM64. Fixes #71268 Change-Id: I3eba9c05b88ed6eb70350d30f6e805e6a4dddbf1 Reviewed-on: https://go-review.googlesource.com/c/go/+/698099 Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Junyang Shao <shaojunyang@google.com>
Diffstat (limited to 'test/codegen')
-rw-r--r--test/codegen/comparisons.go44
1 files changed, 38 insertions, 6 deletions
diff --git a/test/codegen/comparisons.go b/test/codegen/comparisons.go
index 330497c656..43b95646eb 100644
--- a/test/codegen/comparisons.go
+++ b/test/codegen/comparisons.go
@@ -462,7 +462,7 @@ func CmpToZero_ex5(e, f int32, u uint32) int {
func UintLtZero(a uint8, b uint16, c uint32, d uint64) int {
// amd64: -`(TESTB|TESTW|TESTL|TESTQ|JCC|JCS)`
- // arm64: -`(CMPW|CMP|BHS|BLO)`
+ // arm64: -`(CMPW|CMP|CCMP|CCMPW|BHS|BLO)`
if a < 0 || b < 0 || c < 0 || d < 0 {
return 1
}
@@ -471,7 +471,7 @@ func UintLtZero(a uint8, b uint16, c uint32, d uint64) int {
func UintGeqZero(a uint8, b uint16, c uint32, d uint64) int {
// amd64: -`(TESTB|TESTW|TESTL|TESTQ|JCS|JCC)`
- // arm64: -`(CMPW|CMP|BLO|BHS)`
+ // arm64: -`(CMPW|CMP|CCMP|CCMPW|BLO|BHS)`
if a >= 0 || b >= 0 || c >= 0 || d >= 0 {
return 1
}
@@ -479,7 +479,7 @@ func UintGeqZero(a uint8, b uint16, c uint32, d uint64) int {
}
func UintGtZero(a uint8, b uint16, c uint32, d uint64) int {
- // arm64: `(CBN?ZW)`, `(CBN?Z[^W])`, -`(CMPW|CMP|BLS|BHI)`
+ // arm64: `(CMPW|CMP|CCMP|CCMPW|BNE|BEQ)`
if a > 0 || b > 0 || c > 0 || d > 0 {
return 1
}
@@ -487,7 +487,7 @@ func UintGtZero(a uint8, b uint16, c uint32, d uint64) int {
}
func UintLeqZero(a uint8, b uint16, c uint32, d uint64) int {
- // arm64: `(CBN?ZW)`, `(CBN?Z[^W])`, -`(CMPW|CMP|BHI|BLS)`
+ // arm64: `(CMPW|CMP|CCMP|CCMPW|BNE|BEQ)`
if a <= 0 || b <= 0 || c <= 0 || d <= 0 {
return 1
}
@@ -495,7 +495,7 @@ func UintLeqZero(a uint8, b uint16, c uint32, d uint64) int {
}
func UintLtOne(a uint8, b uint16, c uint32, d uint64) int {
- // arm64: `(CBN?ZW)`, `(CBN?Z[^W])`, -`(CMPW|CMP|BHS|BLO)`
+ // arm64: `(CMPW|CMP|CCMP|CCMPW|BNE|BEQ)`
if a < 1 || b < 1 || c < 1 || d < 1 {
return 1
}
@@ -503,13 +503,45 @@ func UintLtOne(a uint8, b uint16, c uint32, d uint64) int {
}
func UintGeqOne(a uint8, b uint16, c uint32, d uint64) int {
- // arm64: `(CBN?ZW)`, `(CBN?Z[^W])`, -`(CMPW|CMP|BLO|BHS)`
+ // arm64: `(CMPW|CMP|CCMP|CCMPW|BNE|BEQ)`
if a >= 1 || b >= 1 || c >= 1 || d >= 1 {
return 1
}
return 0
}
+func ConditionalCompareUint8(a, b uint8) int {
+ // arm64:"CCMPW EQ, R[0-9]+, [$]1, [$]0"
+ if a == 1 && b == 1 {
+ return 1
+ }
+ return 0
+}
+
+func ConditionalCompareInt16(a, b int16) int {
+ // arm64:"CCMPW LE, R[0-9]+, R[0-9]+, [$]4"
+ if a > 3 || a == b {
+ return 1
+ }
+ return 0
+}
+
+func ConditionalCompareUint32(a, b uint32) int {
+ // arm64:"CCMPW LO, R[0-9]+, [$]28, [$]2"
+ if a > b && a < 28 {
+ return 1
+ }
+ return 0
+}
+
+func ConditionalCompareInt64(a, b int64) int {
+ // arm64:"CCMP GT, R[0-9]+, R[0-9]+, [$]0"
+ if a <= 16 || a != b {
+ return 1
+ }
+ return 0
+}
+
func CmpToZeroU_ex1(a uint8, b uint16, c uint32, d uint64) int {
// wasm:"I64Eqz"-"I64LtU"
if 0 < a {