aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2024-05-06 20:18:00 +0000
committerCherry Mui <cherryyz@google.com>2024-05-06 21:03:27 +0000
commit78d89b2b67e26f1e56357f37cdaefe5a2207b4d3 (patch)
tree0e461f04a0b1ddc8fd31ed803ede647b2f8a9dc7
parent58e77ad9b9e2b3323c1d8c1cb5e701412e206368 (diff)
downloadgo-78d89b2b67e26f1e56357f37cdaefe5a2207b4d3.tar.gz
go-78d89b2b67e26f1e56357f37cdaefe5a2207b4d3.zip
[release-branch.go1.21] Revert "cmd/compile: don't combine loads in generated equality functions"
This reverts CL 583303. Reason for revert: release branch is currently frozen. Change-Id: Icbdb73b5b40690a875497dd0dc57ca84c728ef6f Reviewed-on: https://go-review.googlesource.com/c/go/+/582961 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
-rw-r--r--src/cmd/compile/internal/compare/compare.go7
-rw-r--r--test/fixedbugs/issue67160.go32
2 files changed, 1 insertions, 38 deletions
diff --git a/src/cmd/compile/internal/compare/compare.go b/src/cmd/compile/internal/compare/compare.go
index e848e1c858..1674065556 100644
--- a/src/cmd/compile/internal/compare/compare.go
+++ b/src/cmd/compile/internal/compare/compare.go
@@ -148,7 +148,7 @@ func calculateCostForType(t *types.Type) int64 {
return EqStructCost(t)
case types.TSLICE:
// Slices are not comparable.
- base.Fatalf("calculateCostForType: unexpected slice type")
+ base.Fatalf("eqStructFieldCost: unexpected slice type")
case types.TARRAY:
elemCost := calculateCostForType(t.Elem())
cost = t.NumElem() * elemCost
@@ -374,11 +374,6 @@ func eqmem(p ir.Node, q ir.Node, field *types.Sym, size int64) ir.Node {
}
func eqmemfunc(size int64, t *types.Type) (fn *ir.Name, needsize bool) {
- if !base.Ctxt.Arch.CanMergeLoads && t.Alignment() < int64(base.Ctxt.Arch.Alignment) && t.Alignment() < t.Size() {
- // We can't use larger comparisons if the value might not be aligned
- // enough for the larger comparison. See issues 46283 and 67160.
- size = 0
- }
switch size {
default:
fn = typecheck.LookupRuntime("memequal")
diff --git a/test/fixedbugs/issue67160.go b/test/fixedbugs/issue67160.go
deleted file mode 100644
index be45a61420..0000000000
--- a/test/fixedbugs/issue67160.go
+++ /dev/null
@@ -1,32 +0,0 @@
-// run
-
-// Copyright 2024 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Test to make sure that we don't try using larger loads for
-// generated equality functions on architectures that can't do
-// unaligned loads.
-
-package main
-
-// T has a big field that wants to be compared with larger loads/stores.
-// T is "special" because of the unnamed field, so it needs a generated equality function.
-// T is an odd number of bytes in size and has alignment 1.
-type T struct {
- src [8]byte
- _ byte
-}
-
-// U contains 8 copies of T, each at a different %8 alignment.
-type U [8]T
-
-//go:noinline
-func f(x, y *U) bool {
- return *x == *y
-}
-
-func main() {
- var a U
- _ = f(&a, &a)
-}