[go] cmd/compile: make indvar min limit visible in its block

10 views
Skip to first unread message

Junyang Shao (Gerrit)

unread,
Jun 15, 2026, 4:30:30 PMJun 15
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Junyang Shao has uploaded the change for review

Commit message

cmd/compile: make indvar min limit visible in its block

The induction variable min limits are only visible in the loop body
prior to this CL. However, the min should also be effective in blocks
dominated by the induction variable's block.

This CL makes that happen.
Change-Id: Icfaec28d67161aa4f02667bfd5f091ed2a6f872c

Change diff

diff --git a/src/cmd/compile/internal/ssa/prove.go b/src/cmd/compile/internal/ssa/prove.go
index d66e3e1..2b130f85 100644
--- a/src/cmd/compile/internal/ssa/prove.go
+++ b/src/cmd/compile/internal/ssa/prove.go
@@ -1603,6 +1603,7 @@
func prove(f *Func) {
// Find induction variables.
var indVars map[*Block][]indVar
+ var headerIndVars map[*Block][]indVar
for _, v := range findIndVar(f) {
ind := v.ind
if len(ind.Args) != 2 {
@@ -1616,8 +1617,10 @@
// ind or nxt is used inside the loop, add it for the facts table
if indVars == nil {
indVars = make(map[*Block][]indVar)
+ headerIndVars = make(map[*Block][]indVar)
}
indVars[v.entry] = append(indVars[v.entry], v)
+ headerIndVars[ind.Block] = append(headerIndVars[ind.Block], v)
continue
} else {
// Since this induction variable is not used for anything but counting the iterations,
@@ -1705,10 +1708,19 @@
case descend:
ft.checkpoint()

+ indVarsSeen := map[indVar]struct{}{}
// Entering the block, add facts about the induction variable
// that is bound to this block.
for _, iv := range indVars[node.block] {
addIndVarRestrictions(ft, parent, iv)
+ indVarsSeen[iv] = struct{}{}
+ }
+
+ // Entering a loop header block, add facts about the induction variables' lower bounds.
+ for _, iv := range headerIndVars[node.block] {
+ if _, ok := indVarsSeen[iv]; !ok {
+ addIndVarMinRestrictions(ft, parent, iv)
+ }
}

// Add results of reaching this block via a branch from
@@ -2254,6 +2266,22 @@
return unknown
}

+// addIndVarMinRestrictions updates the factsTables ft with the starting lower bound
+// learned from the induction variable indVar which drives the loop
+// starting in Block b.
+func addIndVarMinRestrictions(ft *factsTable, b *Block, iv indVar) {
+ d := signed
+ if ft.isNonNegative(iv.min) {
+ d |= unsigned
+ }
+
+ if iv.flags&indVarMinExc == 0 {
+ addRestrictions(b, ft, d, iv.min, iv.ind, lt|eq)
+ } else {
+ addRestrictions(b, ft, d, iv.min, iv.ind, lt)
+ }
+}
+
// addIndVarRestrictions updates the factsTables ft with the facts
// learned from the induction variable indVar which drives the loop
// starting in Block b.
diff --git a/src/runtime/vdso_test.go b/src/runtime/vdso_test.go
index 6c4fbc8..d37025c 100644
--- a/src/runtime/vdso_test.go
+++ b/src/runtime/vdso_test.go
@@ -22,6 +22,7 @@
// TestUsingVDSO tests that we are actually using the VDSO to fetch
// the time.
func TestUsingVDSO(t *testing.T) {
+ t.Skip("1")
if asan.Enabled {
t.Skip("test fails with ASAN beause the ASAN leak checker won't run under strace")
}
diff --git a/test/prove.go b/test/prove.go
index 972493a..20d801f 100644
--- a/test/prove.go
+++ b/test/prove.go
@@ -2928,5 +2928,16 @@
}
}

+func testConsecutiveLoops(buf []byte) {
+ i := 0
+ n := len(buf)
+ for ; i <= n-128; i += 128 { // ERROR "Induction variable:"
+ _ = buf[i : i+32] // ERROR "Proved IsSliceInBounds"
+ }
+ for ; i <= n-32; i += 32 { // ERROR "Induction variable:"
+ _ = buf[i : i+32] // ERROR "Proved IsSliceInBounds"
+ }
+}
+
func main() {
}

Change information

Files:
  • M src/cmd/compile/internal/ssa/prove.go
  • M src/runtime/vdso_test.go
  • M test/prove.go
Change size: S
Delta: 3 files changed, 40 insertions(+), 0 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Icfaec28d67161aa4f02667bfd5f091ed2a6f872c
Gerrit-Change-Number: 790961
Gerrit-PatchSet: 1
Gerrit-Owner: Junyang Shao <shaoj...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Junyang Shao (Gerrit)

unread,
Jun 16, 2026, 1:37:05 PMJun 16
to goph...@pubsubhelper.golang.org, Keith Randall, David Chase, golang-co...@googlegroups.com
Attention needed from David Chase and Keith Randall

Junyang Shao voted and added 1 comment

Votes added by Junyang Shao

Commit-Queue+1
Hold+1

1 comment

Patchset-level comments
File-level comment, Patchset 3 (Latest):
Junyang Shao . unresolved

Wait for release

Open in Gerrit

Related details

Attention is currently required from:
  • David Chase
  • Keith Randall
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Holds
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Icfaec28d67161aa4f02667bfd5f091ed2a6f872c
    Gerrit-Change-Number: 790961
    Gerrit-PatchSet: 3
    Gerrit-Owner: Junyang Shao <shaoj...@google.com>
    Gerrit-Reviewer: David Chase <drc...@google.com>
    Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
    Gerrit-Reviewer: Keith Randall <k...@golang.org>
    Gerrit-Attention: Keith Randall <k...@golang.org>
    Gerrit-Attention: David Chase <drc...@google.com>
    Gerrit-Comment-Date: Tue, 16 Jun 2026 17:37:01 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    unsatisfied_requirement
    open
    diffy

    Junyang Shao (Gerrit)

    unread,
    Jun 16, 2026, 1:41:00 PMJun 16
    to goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, golang-co...@googlegroups.com
    Attention needed from David Chase and Keith Randall

    Junyang Shao voted

    Commit-Queue+1
    Hold+1
    Open in Gerrit

    Related details

    Attention is currently required from:
    • David Chase
    • Keith Randall
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Holds
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Icfaec28d67161aa4f02667bfd5f091ed2a6f872c
    Gerrit-Change-Number: 790961
    Gerrit-PatchSet: 4
    Gerrit-Owner: Junyang Shao <shaoj...@google.com>
    Gerrit-Reviewer: David Chase <drc...@google.com>
    Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
    Gerrit-Reviewer: Keith Randall <k...@golang.org>
    Gerrit-Attention: Keith Randall <k...@golang.org>
    Gerrit-Attention: David Chase <drc...@google.com>
    Gerrit-Comment-Date: Tue, 16 Jun 2026 17:40:55 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    unsatisfied_requirement
    open
    diffy

    Junyang Shao (Gerrit)

    unread,
    Jun 16, 2026, 1:42:45 PMJun 16
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from David Chase, Junyang Shao and Keith Randall

    Junyang Shao uploaded new patchset

    Junyang Shao uploaded patch set #5 to this change.
    Open in Gerrit

    Related details

    Attention is currently required from:
    • David Chase
    • Junyang Shao
    • Keith Randall
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Holds
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Icfaec28d67161aa4f02667bfd5f091ed2a6f872c
    Gerrit-Change-Number: 790961
    Gerrit-PatchSet: 5
    Gerrit-Owner: Junyang Shao <shaoj...@google.com>
    Gerrit-Reviewer: David Chase <drc...@google.com>
    Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
    Gerrit-Reviewer: Keith Randall <k...@golang.org>
    Gerrit-Attention: Keith Randall <k...@golang.org>
    Gerrit-Attention: David Chase <drc...@google.com>
    Gerrit-Attention: Junyang Shao <shaoj...@google.com>
    unsatisfied_requirement
    open
    diffy

    Junyang Shao (Gerrit)

    unread,
    Jun 16, 2026, 1:42:54 PMJun 16
    to goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, golang-co...@googlegroups.com
    Attention needed from David Chase and Keith Randall

    Junyang Shao voted

    Commit-Queue+1
    Hold+1
    Open in Gerrit

    Related details

    Attention is currently required from:
    • David Chase
    • Keith Randall
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Holds
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Icfaec28d67161aa4f02667bfd5f091ed2a6f872c
    Gerrit-Change-Number: 790961
    Gerrit-PatchSet: 5
    Gerrit-Owner: Junyang Shao <shaoj...@google.com>
    Gerrit-Reviewer: David Chase <drc...@google.com>
    Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
    Gerrit-Reviewer: Keith Randall <k...@golang.org>
    Gerrit-Attention: Keith Randall <k...@golang.org>
    Gerrit-Attention: David Chase <drc...@google.com>
    Gerrit-Comment-Date: Tue, 16 Jun 2026 17:42:49 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    unsatisfied_requirement
    open
    diffy

    Keith Randall (Gerrit)

    unread,
    Jun 16, 2026, 3:55:45 PMJun 16
    to Junyang Shao, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, golang-co...@googlegroups.com
    Attention needed from David Chase, Junyang Shao and Keith Randall

    Keith Randall added 1 comment

    Patchset-level comments
    Junyang Shao . unresolved

    Wait for release

    Keith Randall

    Generally if you want to mark something as wait for release, add a hashtag "wait-release", and don't use Hold.
    (I generally don't review things marked Hold, but I will review wait-release ones.)

    Unless you really are Holding this for some other reason also.

    (Same for the other CL in this stack.)

    Open in Gerrit

    Related details

    Attention is currently required from:
    • David Chase
    • Junyang Shao
    • Keith Randall
    Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Holds
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: Icfaec28d67161aa4f02667bfd5f091ed2a6f872c
      Gerrit-Change-Number: 790961
      Gerrit-PatchSet: 5
      Gerrit-Owner: Junyang Shao <shaoj...@google.com>
      Gerrit-Reviewer: David Chase <drc...@google.com>
      Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
      Gerrit-Reviewer: Keith Randall <k...@golang.org>
      Gerrit-CC: Keith Randall <k...@google.com>
      Gerrit-Attention: Keith Randall <k...@golang.org>
      Gerrit-Attention: David Chase <drc...@google.com>
      Gerrit-Attention: Junyang Shao <shaoj...@google.com>
      Gerrit-Comment-Date: Tue, 16 Jun 2026 19:55:40 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Junyang Shao <shaoj...@google.com>
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Junyang Shao (Gerrit)

      unread,
      Jun 16, 2026, 3:59:38 PMJun 16
      to goph...@pubsubhelper.golang.org, Keith Randall, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, David Chase, golang-co...@googlegroups.com
      Attention needed from David Chase, Keith Randall and Keith Randall

      Junyang Shao voted and added 1 comment

      Votes added by Junyang Shao

      Hold+0

      1 comment

      Patchset-level comments
      File-level comment, Patchset 3:
      Junyang Shao . resolved

      Wait for release

      Keith Randall

      Generally if you want to mark something as wait for release, add a hashtag "wait-release", and don't use Hold.
      (I generally don't review things marked Hold, but I will review wait-release ones.)

      Unless you really are Holding this for some other reason also.

      (Same for the other CL in this stack.)

      Junyang Shao

      Ohhh got it! Just done.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • David Chase
      • Keith Randall
      • Keith Randall
      Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        • requirement satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: Icfaec28d67161aa4f02667bfd5f091ed2a6f872c
        Gerrit-Change-Number: 790961
        Gerrit-PatchSet: 6
        Gerrit-Owner: Junyang Shao <shaoj...@google.com>
        Gerrit-Reviewer: David Chase <drc...@google.com>
        Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
        Gerrit-Reviewer: Keith Randall <k...@golang.org>
        Gerrit-CC: Keith Randall <k...@google.com>
        Gerrit-Attention: Keith Randall <k...@golang.org>
        Gerrit-Attention: David Chase <drc...@google.com>
        Gerrit-Attention: Keith Randall <k...@google.com>
        Gerrit-Comment-Date: Tue, 16 Jun 2026 19:59:34 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        Comment-In-Reply-To: Keith Randall <k...@google.com>
        Comment-In-Reply-To: Junyang Shao <shaoj...@google.com>
        unsatisfied_requirement
        satisfied_requirement
        open
        diffy

        Keith Randall (Gerrit)

        unread,
        Jun 17, 2026, 10:57:13 AMJun 17
        to Junyang Shao, goph...@pubsubhelper.golang.org, Keith Randall, Michael Matloob, Keith Randall, golang...@luci-project-accounts.iam.gserviceaccount.com, David Chase, golang-co...@googlegroups.com
        Attention needed from David Chase, Junyang Shao, Keith Randall and Michael Matloob

        Keith Randall voted and added 1 comment

        Votes added by Keith Randall

        Code-Review+2

        1 comment

        File src/cmd/compile/internal/ssa/loopbce.go
        Line 482, Patchset 6 (Parent): b.Func.Warnl(b.Pos, "Induction variable: limits %v%v,%v%v, increment %d%s", mb1, mlim1, mlim2, mb2, inc, extra)
        Keith Randall . unresolved

        Add "downward" here somehow.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • David Chase
        • Junyang Shao
        • Keith Randall
        • Michael Matloob
        Submit Requirements:
        • requirement satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedNo-Wait-Release
        • requirement is not satisfiedReview-Enforcement
        • requirement satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: Icfaec28d67161aa4f02667bfd5f091ed2a6f872c
        Gerrit-Change-Number: 790961
        Gerrit-PatchSet: 6
        Gerrit-Owner: Junyang Shao <shaoj...@google.com>
        Gerrit-Reviewer: David Chase <drc...@google.com>
        Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
        Gerrit-Reviewer: Keith Randall <k...@golang.org>
        Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
        Gerrit-Attention: Michael Matloob <mat...@golang.org>
        Gerrit-Attention: David Chase <drc...@google.com>
        Gerrit-Attention: Keith Randall <k...@google.com>
        Gerrit-Attention: Junyang Shao <shaoj...@google.com>
        Gerrit-Comment-Date: Wed, 17 Jun 2026 14:57:09 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Junyang Shao (Gerrit)

        unread,
        Jun 17, 2026, 1:33:50 PMJun 17
        to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
        Attention needed from David Chase, Junyang Shao, Keith Randall and Michael Matloob

        Junyang Shao uploaded new patchset

        Junyang Shao uploaded patch set #7 to this change.
        Following approvals got outdated and were removed:
        Open in Gerrit

        Related details

        Attention is currently required from:
        • David Chase
        • Junyang Shao
        • Keith Randall
        • Michael Matloob
        Submit Requirements:
          • requirement satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedNo-Wait-Release
          • requirement is not satisfiedReview-Enforcement
          • requirement is not satisfiedTryBots-Pass
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: newpatchset
          Gerrit-Project: go
          Gerrit-Branch: master
          Gerrit-Change-Id: Icfaec28d67161aa4f02667bfd5f091ed2a6f872c
          Gerrit-Change-Number: 790961
          Gerrit-PatchSet: 7
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Junyang Shao (Gerrit)

          unread,
          Jun 17, 2026, 1:34:07 PMJun 17
          to goph...@pubsubhelper.golang.org, Keith Randall, Michael Matloob, Keith Randall, golang...@luci-project-accounts.iam.gserviceaccount.com, David Chase, golang-co...@googlegroups.com
          Attention needed from David Chase, Keith Randall and Michael Matloob

          Junyang Shao voted and added 1 comment

          Votes added by Junyang Shao

          Commit-Queue+1

          1 comment

          File src/cmd/compile/internal/ssa/loopbce.go
          Line 482, Patchset 6 (Parent): b.Func.Warnl(b.Pos, "Induction variable: limits %v%v,%v%v, increment %d%s", mb1, mlim1, mlim2, mb2, inc, extra)
          Keith Randall . resolved

          Add "downward" here somehow.

          Junyang Shao

          Done

          Open in Gerrit

          Related details

          Attention is currently required from:
          • David Chase
          • Keith Randall
          • Michael Matloob
          Submit Requirements:
          • requirement satisfiedCode-Review
          • requirement satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedNo-Wait-Release
          • requirement is not satisfiedReview-Enforcement
          • requirement is not satisfiedTryBots-Pass
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: go
          Gerrit-Branch: master
          Gerrit-Change-Id: Icfaec28d67161aa4f02667bfd5f091ed2a6f872c
          Gerrit-Change-Number: 790961
          Gerrit-PatchSet: 7
          Gerrit-Owner: Junyang Shao <shaoj...@google.com>
          Gerrit-Reviewer: David Chase <drc...@google.com>
          Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
          Gerrit-Reviewer: Keith Randall <k...@golang.org>
          Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
          Gerrit-CC: Keith Randall <k...@google.com>
          Gerrit-Attention: Michael Matloob <mat...@golang.org>
          Gerrit-Attention: David Chase <drc...@google.com>
          Gerrit-Attention: Keith Randall <k...@google.com>
          Gerrit-Comment-Date: Wed, 17 Jun 2026 17:34:03 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          Comment-In-Reply-To: Keith Randall <k...@golang.org>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Russ Cox (Gerrit)

          unread,
          Jul 15, 2026, 2:18:42 PMJul 15
          to Junyang Shao, goph...@pubsubhelper.golang.org, Russ Cox, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, Michael Matloob, Keith Randall, David Chase, golang-co...@googlegroups.com
          Attention needed from David Chase, Junyang Shao, Keith Randall and Michael Matloob

          Russ Cox voted Code-Review+1

          Code-Review+1
          Open in Gerrit

          Related details

          Attention is currently required from:
          • David Chase
          • Junyang Shao
          • Keith Randall
          • Michael Matloob
          Submit Requirements:
            • requirement satisfiedCode-Review
            • requirement satisfiedNo-Unresolved-Comments
            • requirement satisfiedReview-Enforcement
            • requirement satisfiedTryBots-Pass
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: go
            Gerrit-Branch: master
            Gerrit-Change-Id: Icfaec28d67161aa4f02667bfd5f091ed2a6f872c
            Gerrit-Change-Number: 790961
            Gerrit-PatchSet: 7
            Gerrit-Owner: Junyang Shao <shaoj...@google.com>
            Gerrit-Reviewer: David Chase <drc...@google.com>
            Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
            Gerrit-Reviewer: Keith Randall <k...@golang.org>
            Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
            Gerrit-Reviewer: Russ Cox <r...@golang.org>
            Gerrit-CC: Keith Randall <k...@google.com>
            Gerrit-Attention: Michael Matloob <mat...@golang.org>
            Gerrit-Attention: David Chase <drc...@google.com>
            Gerrit-Attention: Keith Randall <k...@google.com>
            Gerrit-Attention: Junyang Shao <shaoj...@google.com>
            Gerrit-Comment-Date: Wed, 15 Jul 2026 18:18:37 +0000
            Gerrit-HasComments: No
            Gerrit-Has-Labels: Yes
            satisfied_requirement
            open
            diffy

            Junyang Shao (Gerrit)

            unread,
            Sep 1, 2026, 1:41:40 PM (2 days ago) Sep 1
            to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
            Attention needed from David Chase, Junyang Shao, Keith Randall, Keith Randall, Michael Matloob and Russ Cox

            Junyang Shao uploaded new patchset

            Junyang Shao uploaded patch set #8 to this change.
            Following approvals got outdated and were removed:
            Open in Gerrit

            Related details

            Attention is currently required from:
            • David Chase
            • Junyang Shao
            • Keith Randall
            • Keith Randall
            • Michael Matloob
            • Russ Cox
            Submit Requirements:
            • requirement is not satisfiedCode-Review
            • requirement satisfiedNo-Unresolved-Comments
            • requirement is not satisfiedReview-Enforcement
            • requirement is not satisfiedTryBots-Pass
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: newpatchset
            Gerrit-Project: go
            Gerrit-Branch: master
            Gerrit-Change-Id: Icfaec28d67161aa4f02667bfd5f091ed2a6f872c
            Gerrit-Change-Number: 790961
            Gerrit-PatchSet: 8
            Gerrit-Owner: Junyang Shao <shaoj...@google.com>
            Gerrit-Reviewer: David Chase <drc...@google.com>
            Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
            Gerrit-Reviewer: Keith Randall <k...@golang.org>
            Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
            Gerrit-Reviewer: Russ Cox <r...@golang.org>
            Gerrit-CC: Keith Randall <k...@google.com>
            Gerrit-Attention: Russ Cox <r...@golang.org>
            Gerrit-Attention: Keith Randall <k...@golang.org>
            unsatisfied_requirement
            satisfied_requirement
            open
            diffy

            Junyang Shao (Gerrit)

            unread,
            Sep 1, 2026, 2:06:01 PM (2 days ago) Sep 1
            to goph...@pubsubhelper.golang.org, Russ Cox, golang...@luci-project-accounts.iam.gserviceaccount.com, Keith Randall, Michael Matloob, Keith Randall, David Chase, golang-co...@googlegroups.com
            Attention needed from David Chase, Keith Randall, Keith Randall, Michael Matloob and Russ Cox

            Junyang Shao voted

            Auto-Submit+1
            Commit-Queue+1
            Open in Gerrit

            Related details

            Attention is currently required from:
            • David Chase
            • Keith Randall
            • Keith Randall
            • Michael Matloob
            • Russ Cox
            Submit Requirements:
            • requirement is not satisfiedCode-Review
            • requirement satisfiedNo-Unresolved-Comments
            • requirement is not satisfiedReview-Enforcement
            • requirement is not satisfiedTryBots-Pass
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: go
            Gerrit-Branch: master
            Gerrit-Change-Id: Icfaec28d67161aa4f02667bfd5f091ed2a6f872c
            Gerrit-Change-Number: 790961
            Gerrit-PatchSet: 9
            Gerrit-Owner: Junyang Shao <shaoj...@google.com>
            Gerrit-Reviewer: David Chase <drc...@google.com>
            Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
            Gerrit-Reviewer: Keith Randall <k...@golang.org>
            Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
            Gerrit-Reviewer: Russ Cox <r...@golang.org>
            Gerrit-CC: Keith Randall <k...@google.com>
            Gerrit-Attention: Russ Cox <r...@golang.org>
            Gerrit-Attention: Keith Randall <k...@golang.org>
            Gerrit-Attention: Michael Matloob <mat...@golang.org>
            Gerrit-Attention: David Chase <drc...@google.com>
            Gerrit-Attention: Keith Randall <k...@google.com>
            Gerrit-Comment-Date: Tue, 01 Sep 2026 18:05:53 +0000
            Gerrit-HasComments: No
            Gerrit-Has-Labels: Yes
            unsatisfied_requirement
            satisfied_requirement
            open
            diffy

            David Chase (Gerrit)

            unread,
            Sep 1, 2026, 3:56:39 PM (2 days ago) Sep 1
            to Junyang Shao, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Russ Cox, Keith Randall, Michael Matloob, Keith Randall, golang-co...@googlegroups.com
            Attention needed from Junyang Shao, Keith Randall, Keith Randall, Michael Matloob and Russ Cox

            David Chase added 1 comment

            File src/cmd/compile/internal/ssacompile/prove.go
            Line 1351, Patchset 9 (Latest): // Entering a loop header block, add facts about the induction variables' init bounds.
            David Chase . unresolved

            How do we know this is a loop header block? Or is this "if it is a loop header block, ..."?

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Junyang Shao
            • Keith Randall
            • Keith Randall
            • Michael Matloob
            • Russ Cox
              Submit Requirements:
                • requirement is not satisfiedCode-Review
                • requirement is not satisfiedNo-Unresolved-Comments
                • requirement is not satisfiedReview-Enforcement
                • requirement satisfiedTryBots-Pass
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: comment
                Gerrit-Project: go
                Gerrit-Branch: master
                Gerrit-Change-Id: Icfaec28d67161aa4f02667bfd5f091ed2a6f872c
                Gerrit-Change-Number: 790961
                Gerrit-PatchSet: 9
                Gerrit-Owner: Junyang Shao <shaoj...@google.com>
                Gerrit-Reviewer: David Chase <drc...@google.com>
                Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
                Gerrit-Reviewer: Keith Randall <k...@golang.org>
                Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
                Gerrit-Reviewer: Russ Cox <r...@golang.org>
                Gerrit-CC: Keith Randall <k...@google.com>
                Gerrit-Attention: Russ Cox <r...@golang.org>
                Gerrit-Attention: Keith Randall <k...@golang.org>
                Gerrit-Attention: Michael Matloob <mat...@golang.org>
                Gerrit-Attention: Keith Randall <k...@google.com>
                Gerrit-Attention: Junyang Shao <shaoj...@google.com>
                Gerrit-Comment-Date: Tue, 01 Sep 2026 19:56:34 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: No
                unsatisfied_requirement
                satisfied_requirement
                open
                diffy

                Junyang Shao (Gerrit)

                unread,
                Sep 1, 2026, 4:33:13 PM (2 days ago) Sep 1
                to goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Russ Cox, Keith Randall, Michael Matloob, Keith Randall, David Chase, golang-co...@googlegroups.com
                Attention needed from David Chase, Keith Randall, Keith Randall, Michael Matloob and Russ Cox

                Junyang Shao added 1 comment

                File src/cmd/compile/internal/ssacompile/prove.go
                Line 1351, Patchset 9 (Latest): // Entering a loop header block, add facts about the induction variables' init bounds.
                David Chase . resolved

                How do we know this is a loop header block? Or is this "if it is a loop header block, ..."?

                Junyang Shao

                I think this is the block that defines the induction variable, which is the header block?

                Open in Gerrit

                Related details

                Attention is currently required from:
                • David Chase
                • Keith Randall
                • Keith Randall
                • Michael Matloob
                • Russ Cox
                  Submit Requirements:
                    • requirement is not satisfiedCode-Review
                    • requirement satisfiedNo-Unresolved-Comments
                    • requirement is not satisfiedReview-Enforcement
                    • requirement satisfiedTryBots-Pass
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: go
                    Gerrit-Branch: master
                    Gerrit-Change-Id: Icfaec28d67161aa4f02667bfd5f091ed2a6f872c
                    Gerrit-Change-Number: 790961
                    Gerrit-PatchSet: 9
                    Gerrit-Owner: Junyang Shao <shaoj...@google.com>
                    Gerrit-Reviewer: David Chase <drc...@google.com>
                    Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
                    Gerrit-Reviewer: Keith Randall <k...@golang.org>
                    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
                    Gerrit-Reviewer: Russ Cox <r...@golang.org>
                    Gerrit-CC: Keith Randall <k...@google.com>
                    Gerrit-Attention: Russ Cox <r...@golang.org>
                    Gerrit-Attention: Keith Randall <k...@golang.org>
                    Gerrit-Attention: Michael Matloob <mat...@golang.org>
                    Gerrit-Attention: David Chase <drc...@google.com>
                    Gerrit-Attention: Keith Randall <k...@google.com>
                    Gerrit-Comment-Date: Tue, 01 Sep 2026 20:33:08 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    Comment-In-Reply-To: David Chase <drc...@google.com>
                    unsatisfied_requirement
                    satisfied_requirement
                    open
                    diffy

                    David Chase (Gerrit)

                    unread,
                    Sep 1, 2026, 4:42:13 PM (2 days ago) Sep 1
                    to Junyang Shao, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Russ Cox, Keith Randall, Michael Matloob, Keith Randall, golang-co...@googlegroups.com
                    Attention needed from Junyang Shao, Keith Randall, Keith Randall, Michael Matloob and Russ Cox

                    David Chase voted and added 1 comment

                    Votes added by David Chase

                    Code-Review+2

                    1 comment

                    File src/cmd/compile/internal/ssacompile/prove.go
                    Line 1351, Patchset 9 (Latest): // Entering a loop header block, add facts about the induction variables' init bounds.
                    David Chase . resolved

                    How do we know this is a loop header block? Or is this "if it is a loop header block, ..."?

                    Junyang Shao

                    I think this is the block that defines the induction variable, which is the header block?

                    David Chase

                    After looking at the code, I think I believe that, but I had to spend a while looking.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Junyang Shao
                    • Keith Randall
                    • Keith Randall
                    • Michael Matloob
                    • Russ Cox
                      Submit Requirements:
                      • requirement satisfiedCode-Review
                      • requirement satisfiedNo-Unresolved-Comments
                      • requirement satisfiedReview-Enforcement
                      • requirement satisfiedTryBots-Pass
                      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                      Gerrit-MessageType: comment
                      Gerrit-Project: go
                      Gerrit-Branch: master
                      Gerrit-Change-Id: Icfaec28d67161aa4f02667bfd5f091ed2a6f872c
                      Gerrit-Change-Number: 790961
                      Gerrit-PatchSet: 9
                      Gerrit-Owner: Junyang Shao <shaoj...@google.com>
                      Gerrit-Reviewer: David Chase <drc...@google.com>
                      Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
                      Gerrit-Reviewer: Keith Randall <k...@golang.org>
                      Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
                      Gerrit-Reviewer: Russ Cox <r...@golang.org>
                      Gerrit-CC: Keith Randall <k...@google.com>
                      Gerrit-Attention: Russ Cox <r...@golang.org>
                      Gerrit-Attention: Keith Randall <k...@golang.org>
                      Gerrit-Attention: Michael Matloob <mat...@golang.org>
                      Gerrit-Attention: Keith Randall <k...@google.com>
                      Gerrit-Attention: Junyang Shao <shaoj...@google.com>
                      Gerrit-Comment-Date: Tue, 01 Sep 2026 20:42:07 +0000
                      Gerrit-HasComments: Yes
                      Gerrit-Has-Labels: Yes
                      Comment-In-Reply-To: David Chase <drc...@google.com>
                      Comment-In-Reply-To: Junyang Shao <shaoj...@google.com>
                      satisfied_requirement
                      open
                      diffy

                      Gopher Robot (Gerrit)

                      unread,
                      Sep 1, 2026, 4:43:31 PM (2 days ago) Sep 1
                      to Junyang Shao, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, David Chase, golang...@luci-project-accounts.iam.gserviceaccount.com, Russ Cox, Keith Randall, Michael Matloob, Keith Randall, golang-co...@googlegroups.com

                      Gopher Robot submitted the change

                      Change information

                      Commit message:
                      cmd/compile: make indvar min limit visible in its block

                      The induction variable min limits are only visible in the loop body
                      prior to this CL. However, the min should also be effective in blocks
                      dominated by the induction variable's block.

                      This CL makes that happen.

                      This change will benefit SIMD-unrolled loop followed by another SIMD
                      loop and a scalar tail loop pattern:

                      ```
                      func CountUppercaseASCII_AVX2_Unrolled4(buf []byte) int {
                      if !archsimd.X86.AVX2() {
                      return CountUppercaseASCII_ScalarUnrolled4(buf)
                      }
                      cA := archsimd.BroadcastUint8x32('A')
                      cZ := archsimd.BroadcastUint8x32('Z')
                      count0 := 0
                      count1 := 0
                      count2 := 0
                      count3 := 0
                      i := 0
                      n := len(buf)

                      for ; i <= n-128; i += 128 {
                      		v0 := archsimd.LoadUint8x32Slice(buf[i : i+32])
                      v1 := archsimd.LoadUint8x32Slice(buf[i+32 : i+64])
                      v2 := archsimd.LoadUint8x32Slice(buf[i+64 : i+96])
                      v3 := archsimd.LoadUint8x32Slice(buf[i+96 : i+128])
                      mask0 := v0.GreaterEqual(cA).And(v0.LessEqual(cZ))
                      mask1 := v1.GreaterEqual(cA).And(v1.LessEqual(cZ))
                      mask2 := v2.GreaterEqual(cA).And(v2.LessEqual(cZ))
                      mask3 := v3.GreaterEqual(cA).And(v3.LessEqual(cZ))
                      count0 += bits.OnesCount32(mask0.ToBits())
                      count1 += bits.OnesCount32(mask1.ToBits())
                      count2 += bits.OnesCount32(mask2.ToBits())
                      count3 += bits.OnesCount32(mask3.ToBits())

                      }
                      for ; i <= n-32; i += 32 {
                      		v := archsimd.LoadUint8x32Slice(buf[i : i+32])
                      mask := v.GreaterEqual(cA).And(v.LessEqual(cZ))
                      count0 += bits.OnesCount32(mask.ToBits())
                      }
                      if i < n {
                      v := archsimd.LoadUint8x32SlicePart(buf[i:])
                      mask := v.GreaterEqual(cA).And(v.LessEqual(cZ))
                      count0 += bits.OnesCount32(mask.ToBits())
                      }
                      return count0 + count1 + count2 + count3
                      }
                      ```
                      Previously, the tail loops sees the correct upper limit, but since the
                      lower limit was bound to the loop body, after simplify those facts are
                      undone, so that the tail loops sees an unbound lower limit, leading to
                      the not proving the slice in bounds.

                      With this change, the tail loops see the initial lower limit correctly
                      and all bound checks on `buf` could be removed.

                      Updates #79811.
                      Change-Id: Icfaec28d67161aa4f02667bfd5f091ed2a6f872c
                      Auto-Submit: Junyang Shao <shaoj...@google.com>
                      Reviewed-by: David Chase <drc...@google.com>
                      Files:
                      • M src/cmd/compile/internal/ssacompile/loopbce.go
                      • M src/cmd/compile/internal/ssacompile/prove.go
                      • M test/prove.go
                      Change size: M
                      Delta: 3 files changed, 80 insertions(+), 9 deletions(-)
                      Branch: refs/heads/master
                      Submit Requirements:
                      Open in Gerrit
                      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                      Gerrit-MessageType: merged
                      Gerrit-Project: go
                      Gerrit-Branch: master
                      Gerrit-Change-Id: Icfaec28d67161aa4f02667bfd5f091ed2a6f872c
                      Gerrit-Change-Number: 790961
                      Gerrit-PatchSet: 10
                      Gerrit-Owner: Junyang Shao <shaoj...@google.com>
                      Gerrit-Reviewer: David Chase <drc...@google.com>
                      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
                      open
                      diffy
                      satisfied_requirement
                      Reply all
                      Reply to author
                      Forward
                      0 new messages