diff options
| author | Keith Randall <khr@golang.org> | 2025-05-14 15:57:58 -0700 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2025-05-15 14:06:41 -0700 |
| commit | 19f05770b05ef2a12692f522056ffb3bc23583ea (patch) | |
| tree | 4ab751618f2760a972afade30b136e66f4cafb93 /test/codegen | |
| parent | 11fa0de475f9446870bc086bfb42cb67bac40634 (diff) | |
| download | go-19f05770b05ef2a12692f522056ffb3bc23583ea.tar.xz | |
cmd/compile: schedule induction variable increments late
for ..; ..; i++ {
...
}
We want to schedule the i++ late in the block, so that all other
uses of i in the block are scheduled first. That way, i++ can
happen in place in a register instead of requiring a temporary register.
Change-Id: Id777407c7e67a5ddbd8e58251099b0488138c0df
Reviewed-on: https://go-review.googlesource.com/c/go/+/672998
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Diffstat (limited to 'test/codegen')
| -rw-r--r-- | test/codegen/schedule.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/codegen/schedule.go b/test/codegen/schedule.go new file mode 100644 index 0000000000..aafffd817b --- /dev/null +++ b/test/codegen/schedule.go @@ -0,0 +1,17 @@ +// asmcheck + +// Copyright 2025 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 + +func f(n int) int { + r := 0 + // arm64:-"MOVD\t R" + // amd64:-"LEAQ","INCQ" + for i := range n { + r += i + } + return r +} |
