summaryrefslogtreecommitdiffstats
path: root/src/cmd/compile/internal/compare/compare.go
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-08 04:10:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-08 04:10:35 +0000
commitda7e85e4b5d49867c08968d797a7e3bda779a58a (patch)
tree008413f15c1dd8ca9910433d1d089fb06d6ba17d /src/cmd/compile/internal/compare/compare.go
parentAdding upstream version 1.22.3. (diff)
downloadgolang-1.22-da7e85e4b5d49867c08968d797a7e3bda779a58a.tar.xz
golang-1.22-da7e85e4b5d49867c08968d797a7e3bda779a58a.zip
Adding upstream version 1.22.4.upstream/1.22.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/cmd/compile/internal/compare/compare.go')
-rw-r--r--src/cmd/compile/internal/compare/compare.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/compare/compare.go b/src/cmd/compile/internal/compare/compare.go
index e165cd6..cb2f84e 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("eqStructFieldCost: unexpected slice type")
+ base.Fatalf("calculateCostForType: unexpected slice type")
case types.TARRAY:
elemCost := calculateCostForType(t.Elem())
cost = t.NumElem() * elemCost
@@ -371,6 +371,11 @@ func eqmem(p, q ir.Node, field int, 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 {
case 1, 2, 4, 8, 16:
buf := fmt.Sprintf("memequal%d", int(size)*8)