Repository navigation
Conversation
A read at a negative constant offset in a loop with a constant limit, such as dst[i] = a[i-20] + 1 in a loop that stops before 16, was rewritten into code that does not compile: the length check of the vector loop is _ = a[16-21], a negative constant index. -split wrote that file, and the toolexec wrapper fell back to the original package. Such a loop panics as soon as it runs, as does one whose first index is a negative constant (a[i-1] in a loop from 0). Both are now left alone with their own reason, the way a constant limit of zero or less already is. A read whose indexes can all be zero or more (a[i-1] from 1) is still rewritten. The checks read the start and limit as text, so a named constant or a constant expression (const s0 = 0; for i := s0; ...) slipped past them. A constant start or limit is now spelled as its value, which also lets the short-loop rule see a named constant trip count: goav1's for x := range restorationExtraHorz, three iterations, is no longer rewritten. The vectorized set of std and gonum does not change.
thesyncim
force-pushed
the
fix-negative-constant-offset
branch
from
November 1, 2026 13:36
087660e to
00263c0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
loopvec writes a
_simd.gothat doesn't compile for a loop like this:The length check comes out as
_ = a[16-21]:toolexec falls back, but
-splitand-wleave the broken file behind.A loop like that panics as soon as it runs, and so does one whose first index is a negative constant (
a[i-1]starting at 0). Both are now rejected with their own reason, the same way a constant limit of zero or less already is.a[i-1]starting at 1 is still rewritten.The checks parsed the start and limit as text, so named constants and constant expressions (
const s0 = 0; for i := s0; ...,for i := 1 - 1; ...) slipped through. Constant bounds are now written out as their value. A side effect is that the short-loop rule now sees named constant trip counts too: in goav1, a 3-iterationfor x := range restorationExtraHorzis no longer vectorized. The vectorized set of std and gonum doesn't change.