]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: name change isDirect -> isDirectAndComparable
authorKeith Randall <khr@golang.org>
Tue, 28 Oct 2025 17:07:48 +0000 (10:07 -0700)
committerGopher Robot <gobot@golang.org>
Tue, 28 Oct 2025 18:12:30 +0000 (11:12 -0700)
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>

src/cmd/compile/internal/ssa/_gen/generic.rules
src/cmd/compile/internal/ssa/rewrite.go
src/cmd/compile/internal/ssa/rewritegeneric.go

index 61157f7c8f7d180fdbfa2671eacb201edfc4a531..795e9f052e6b2d75c2d5b98a1da7d62753a43933 100644 (file)
 // 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)
 
 // 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)
 
index 2856ff2e4309082dbe65c50c53fca5fd5b0ffad7..c645f06557ca1be20bfa13d678d8f659d8997192 100644 (file)
@@ -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
                        }
                }
index dd005231346d0716fadc84149fcbe972ae049199..2dac0c6cfe43989e9fbe3181334abc33ab8b359d 100644 (file)
@@ -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)