From 19f05770b05ef2a12692f522056ffb3bc23583ea Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Wed, 14 May 2025 15:57:58 -0700 Subject: 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 Reviewed-by: David Chase Reviewed-by: Keith Randall --- test/codegen/schedule.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test/codegen/schedule.go (limited to 'test/codegen') 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 +} -- cgit v1.3