aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2025-10-28 10:07:48 -0700
committerGopher Robot <gobot@golang.org>2025-10-28 11:12:30 -0700
commitea50d61b667276bfd3449d5e172adc4b92f72290 (patch)
tree8e93661aefa20aed0bc1454cc3aca744e1e68cf6 /src/cmd/compile/internal
parentbd4dc413cd80d3c160e875686e1be1eae5d48d4b (diff)
downloadgo-ea50d61b667276bfd3449d5e172adc4b92f72290.tar.xz
cmd/compile: name change isDirect -> isDirectAndComparable
Now that it also restricts to comparable types. Followon to CL 713840. Change-Id: Idd975c3fd16fb51f55360f2fa0b89ab0bf1d00ed Reviewed-on: https://go-review.googlesource.com/c/go/+/715700 Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Mateusz Poliwczak <mpoliwczak34@gmail.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/cmd/compile/internal')
-rw-r--r--src/cmd/compile/internal/ssa/_gen/generic.rules4
-rw-r--r--src/cmd/compile/internal/ssa/rewrite.go30
-rw-r--r--src/cmd/compile/internal/ssa/rewritegeneric.go8
3 files changed, 21 insertions, 21 deletions
diff --git a/src/cmd/compile/internal/ssa/_gen/generic.rules b/src/cmd/compile/internal/ssa/_gen/generic.rules
index 61157f7c8f..795e9f052e 100644
--- a/src/cmd/compile/internal/ssa/_gen/generic.rules
+++ b/src/cmd/compile/internal/ssa/_gen/generic.rules
@@ -2927,7 +2927,7 @@
// we know the underlying type is pointer-ish.
(StaticLECall {f} typ_ x y mem)
&& isSameCall(f, "runtime.efaceeq")
- && isDirectType(typ_)
+ && isDirectAndComparableType(typ_)
&& clobber(v)
=> (MakeResult (EqPtr x y) mem)
@@ -2935,7 +2935,7 @@
// we know the underlying type is pointer-ish.
(StaticLECall {f} itab x y mem)
&& isSameCall(f, "runtime.ifaceeq")
- && isDirectIface(itab)
+ && isDirectAndComparableIface(itab)
&& clobber(v)
=> (MakeResult (EqPtr x y) mem)
diff --git a/src/cmd/compile/internal/ssa/rewrite.go b/src/cmd/compile/internal/ssa/rewrite.go
index 2856ff2e43..c645f06557 100644
--- a/src/cmd/compile/internal/ssa/rewrite.go
+++ b/src/cmd/compile/internal/ssa/rewrite.go
@@ -2624,18 +2624,18 @@ func rewriteStructStore(v *Value) *Value {
return mem
}
-// isDirectType reports whether v represents a type
+// isDirectAndComparableType reports whether v represents a type
// (a *runtime._type) whose value is stored directly in an
// interface (i.e., is pointer or pointer-like) and is comparable.
-func isDirectType(v *Value) bool {
- return isDirectType1(v)
+func isDirectAndComparableType(v *Value) bool {
+ return isDirectAndComparableType1(v)
}
// v is a type
-func isDirectType1(v *Value) bool {
+func isDirectAndComparableType1(v *Value) bool {
switch v.Op {
case OpITab:
- return isDirectType2(v.Args[0])
+ return isDirectAndComparableType2(v.Args[0])
case OpAddr:
lsym := v.Aux.(*obj.LSym)
if ti := lsym.TypeInfo(); ti != nil {
@@ -2647,29 +2647,29 @@ func isDirectType1(v *Value) bool {
}
// v is an empty interface
-func isDirectType2(v *Value) bool {
+func isDirectAndComparableType2(v *Value) bool {
switch v.Op {
case OpIMake:
- return isDirectType1(v.Args[0])
+ return isDirectAndComparableType1(v.Args[0])
}
return false
}
-// isDirectIface reports whether v represents an itab
+// isDirectAndComparableIface reports whether v represents an itab
// (a *runtime._itab) for a type whose value is stored directly
// in an interface (i.e., is pointer or pointer-like) and is comparable.
-func isDirectIface(v *Value) bool {
- return isDirectIface1(v, 9)
+func isDirectAndComparableIface(v *Value) bool {
+ return isDirectAndComparableIface1(v, 9)
}
// v is an itab
-func isDirectIface1(v *Value, depth int) bool {
+func isDirectAndComparableIface1(v *Value, depth int) bool {
if depth == 0 {
return false
}
switch v.Op {
case OpITab:
- return isDirectIface2(v.Args[0], depth-1)
+ return isDirectAndComparableIface2(v.Args[0], depth-1)
case OpAddr:
lsym := v.Aux.(*obj.LSym)
if ii := lsym.ItabInfo(); ii != nil {
@@ -2685,16 +2685,16 @@ func isDirectIface1(v *Value, depth int) bool {
}
// v is an interface
-func isDirectIface2(v *Value, depth int) bool {
+func isDirectAndComparableIface2(v *Value, depth int) bool {
if depth == 0 {
return false
}
switch v.Op {
case OpIMake:
- return isDirectIface1(v.Args[0], depth-1)
+ return isDirectAndComparableIface1(v.Args[0], depth-1)
case OpPhi:
for _, a := range v.Args {
- if !isDirectIface2(a, depth-1) {
+ if !isDirectAndComparableIface2(a, depth-1) {
return false
}
}
diff --git a/src/cmd/compile/internal/ssa/rewritegeneric.go b/src/cmd/compile/internal/ssa/rewritegeneric.go
index dd00523134..2dac0c6cfe 100644
--- a/src/cmd/compile/internal/ssa/rewritegeneric.go
+++ b/src/cmd/compile/internal/ssa/rewritegeneric.go
@@ -32612,7 +32612,7 @@ func rewriteValuegeneric_OpStaticLECall(v *Value) bool {
return true
}
// match: (StaticLECall {f} typ_ x y mem)
- // cond: isSameCall(f, "runtime.efaceeq") && isDirectType(typ_) && clobber(v)
+ // cond: isSameCall(f, "runtime.efaceeq") && isDirectAndComparableType(typ_) && clobber(v)
// result: (MakeResult (EqPtr x y) mem)
for {
if len(v.Args) != 4 {
@@ -32623,7 +32623,7 @@ func rewriteValuegeneric_OpStaticLECall(v *Value) bool {
typ_ := v.Args[0]
x := v.Args[1]
y := v.Args[2]
- if !(isSameCall(f, "runtime.efaceeq") && isDirectType(typ_) && clobber(v)) {
+ if !(isSameCall(f, "runtime.efaceeq") && isDirectAndComparableType(typ_) && clobber(v)) {
break
}
v.reset(OpMakeResult)
@@ -32633,7 +32633,7 @@ func rewriteValuegeneric_OpStaticLECall(v *Value) bool {
return true
}
// match: (StaticLECall {f} itab x y mem)
- // cond: isSameCall(f, "runtime.ifaceeq") && isDirectIface(itab) && clobber(v)
+ // cond: isSameCall(f, "runtime.ifaceeq") && isDirectAndComparableIface(itab) && clobber(v)
// result: (MakeResult (EqPtr x y) mem)
for {
if len(v.Args) != 4 {
@@ -32644,7 +32644,7 @@ func rewriteValuegeneric_OpStaticLECall(v *Value) bool {
itab := v.Args[0]
x := v.Args[1]
y := v.Args[2]
- if !(isSameCall(f, "runtime.ifaceeq") && isDirectIface(itab) && clobber(v)) {
+ if !(isSameCall(f, "runtime.ifaceeq") && isDirectAndComparableIface(itab) && clobber(v)) {
break
}
v.reset(OpMakeResult)