aboutsummaryrefslogtreecommitdiff
path: root/test/codegen/comparisons.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/codegen/comparisons.go')
-rw-r--r--test/codegen/comparisons.go26
1 files changed, 25 insertions, 1 deletions
diff --git a/test/codegen/comparisons.go b/test/codegen/comparisons.go
index 4edf9303dfd..e585045aa47 100644
--- a/test/codegen/comparisons.go
+++ b/test/codegen/comparisons.go
@@ -6,7 +6,10 @@
package codegen
-import "unsafe"
+import (
+ "cmp"
+ "unsafe"
+)
// This file contains code generation tests related to the comparison
// operators.
@@ -801,3 +804,24 @@ func invertLessThanNoov(p1, p2, p3 Point) bool {
// arm64:`CMP`,`CSET`,`CSEL`
return (p1.X-p3.X)*(p2.Y-p3.Y)-(p2.X-p3.X)*(p1.Y-p3.Y) < 0
}
+
+func cmpstring1(x, y string) int {
+ // amd64:".*cmpstring"
+ if x < y {
+ return -1
+ }
+ // amd64:-".*cmpstring"
+ if x > y {
+ return +1
+ }
+ return 0
+}
+func cmpstring2(x, y string) int {
+ // We want to fail if there are two calls to cmpstring.
+ // They will both have the same line number, so a test
+ // like in cmpstring1 will not work. Instead, we
+ // look for spill/restore instructions, which only
+ // need to exist if there are 2 calls.
+ //amd64:-`MOVQ\t.*\(SP\)`
+ return cmp.Compare(x, y)
+}