1
0
mirror of https://github.com/golang/go synced 2024-11-05 11:46:12 -07:00
go/test/codegen/addrcalc.go
Keith Randall 1cfe8e91b6 cmd/compile: use ADDQ instead of LEAQ when we can
The address calculations in the example end up doing x << 4 + y + 0.
Before this CL we use a SHLQ+LEAQ. Since the constant offset is 0,
we can use SHLQ+ADDQ instead.

Change-Id: Ia048c4fdbb3a42121c7e1ab707961062e8247fca
Reviewed-on: https://go-review.googlesource.com/c/go/+/209959
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-02-24 21:33:53 +00:00

15 lines
324 B
Go

// asmcheck
// Copyright 2019 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.
package codegen
// Make sure we use ADDQ instead of LEAQ when we can.
func f(p *[4][2]int, x int) *int {
// amd64:"ADDQ",-"LEAQ"
return &p[x][0]
}