]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: improve loopRotate to handle nested loops
authorAlexander Musman <alexander.musman@gmail.com>
Tue, 13 May 2025 06:44:17 +0000 (09:44 +0300)
committerGopher Robot <gobot@golang.org>
Thu, 24 Jul 2025 19:40:00 +0000 (12:40 -0700)
commit592c2db868c7465ae06a447a861c313ba071f3e6
tree8bca800bcb9d3d7c3c259a14f2da6d2c55b0f054
parentdcb479c2f9e6c379ee01efb3b1fa8a4e784f8503
cmd/compile: improve loopRotate to handle nested loops

Enhance loop rotation of nested loops. Currently, loops are processed independently,
resulting in unnecessary jumps between outer and inner loops. By processing inner
loops before their parent loop, we ensure nested loop blocks are
properly placed within their parent loop's block sequence.

There is some code size improvement (as measured on amd64) due to jumps
to/from inner loop are removed by the updated loopRotate block order:

Executable            Old .text  New .text     Change
-------------------------------------------------------
asm                     2147569    2146481     -0.05%
cgo                     1977457    1975761     -0.09%
compile                10447345   10441905     -0.05%
cover                   2110097    2108977     -0.05%
link                    2930289    2929041     -0.04%
preprofile               927345     926769     -0.06%
vet                     3279057    3277009     -0.06%

Change-Id: I4b9e993c2be07fad735e6bcf32d062d099d9cfb5
Reviewed-on: https://go-review.googlesource.com/c/go/+/684335
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/cmd/compile/internal/ssa/looprotate.go
src/cmd/compile/internal/ssa/looprotate_test.go [new file with mode: 0644]