[go] simd/internal/spec: fix ConvertToZ width rounding

4 views
Skip to first unread message

Austin Clements (Gerrit)

unread,
Sep 5, 2026, 2:25:42 PMSep 5
to David Chase, Junyang Shao, goph...@pubsubhelper.golang.org, Austin Clements, golang-co...@googlegroups.com
Attention needed from David Chase and Junyang Shao

Austin Clements has uploaded the change for review

Austin Clements would like David Chase and Junyang Shao to review this change.

Commit message

simd/internal/spec: fix ConvertToZ width rounding

The current "zL=xL" constraint doesn't apply width rounding, so we
don't get

(Float64x2).ConverToFloat32() Float32x4

This changes the constraint to z={zB}{zN}x{xL}, which does apply width
rounding, so we do get the width-rounded method.
Change-Id: I9248f858459aa83ec516f016e682506771ad7385

Change diff

diff --git a/src/simd/internal/spec/converts.go b/src/simd/internal/spec/converts.go
index 7f24db7..16baea7 100644
--- a/src/simd/internal/spec/converts.go
+++ b/src/simd/internal/spec/converts.go
@@ -9,7 +9,7 @@
// ConvertToZ converts element values to {zE}. The result has the same number of lanes.
//
//specgen:name ConvertTo{zE}
-//specgen:require zL=xL zE!=xE
+//specgen:require z={zB}{zN}x{xL} zE!=xE
func ConvertToZ[xE Nums, xW Width, zE Nums, zW Width](x Vec[xE, xW]) (z Vec[zE, zW]) {
// Architectures are generally significantly more constrained in what they
// will convert between, but this operation describes the full universe of
diff --git a/src/simd/internal/spec/doc.go b/src/simd/internal/spec/doc.go
index 35b8675..1f6d137 100644
--- a/src/simd/internal/spec/doc.go
+++ b/src/simd/internal/spec/doc.go
@@ -104,6 +104,16 @@
// zB=vB zN=vN*2 zL=vL/2 Constrain each component separately
// zE={vB}{vN*2} zW=vW Constrain the element type and width separately
//
+// ### Width rounding
+//
+// Some operations would naturally result in an impossible vector size. For
+// example, converting a Float64x2 vector to float32s would naturally result in
+// Float32x2, which is only 64 bits and thus smaller than the smallest vector
+// size. For operations like this, we use "width rounding".
+//
+// Width rounding is applied specifically by the vector expression form BaseNxL.
+// If NxL would be < 128, the result rounds L up to 128/N.
+//
// ## Name and doc templates
//
// For some operations, the API name or documentation depends on type

Change information

Files:
  • M src/simd/internal/spec/converts.go
  • M src/simd/internal/spec/doc.go
Change size: S
Delta: 2 files changed, 11 insertions(+), 1 deletion(-)
Open in Gerrit

Related details

Attention is currently required from:
  • David Chase
  • Junyang Shao
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: I9248f858459aa83ec516f016e682506771ad7385
Gerrit-Change-Number: 828144
Gerrit-PatchSet: 1
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: David Chase <drc...@google.com>
Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
Gerrit-Attention: David Chase <drc...@google.com>
Gerrit-Attention: Junyang Shao <shaoj...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Junyang Shao (Gerrit)

unread,
Sep 9, 2026, 2:56:51 PMSep 9
to Austin Clements, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, David Chase, golang-co...@googlegroups.com
Attention needed from Austin Clements and David Chase

Junyang Shao voted Code-Review+2

Code-Review+2
Open in Gerrit

Related details

Attention is currently required from:
  • Austin Clements
  • David Chase
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: I9248f858459aa83ec516f016e682506771ad7385
Gerrit-Change-Number: 828144
Gerrit-PatchSet: 1
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: David Chase <drc...@google.com>
Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
Gerrit-Attention: David Chase <drc...@google.com>
Gerrit-Attention: Austin Clements <aus...@google.com>
Gerrit-Comment-Date: Wed, 09 Sep 2026 18:56:47 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Austin Clements (Gerrit)

unread,
Sep 9, 2026, 3:56:52 PMSep 9
to Austin Clements, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Austin Clements and David Chase

Austin Clements uploaded new patchset

Austin Clements uploaded patch set #2 to this change.
Following approvals got outdated and were removed:
Open in Gerrit

Related details

Attention is currently required from:
  • Austin Clements
  • David Chase
Submit Requirements:
    • requirement satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement 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: I9248f858459aa83ec516f016e682506771ad7385
    Gerrit-Change-Number: 828144
    Gerrit-PatchSet: 2
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Gopher Robot (Gerrit)

    unread,
    Sep 10, 2026, 10:59:14 AMSep 10
    to Austin Clements, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, golang...@luci-project-accounts.iam.gserviceaccount.com, Junyang Shao, David Chase, golang-co...@googlegroups.com

    Gopher Robot submitted the change

    Unreviewed changes

    1 is the latest approved patch-set.
    No files were changed between the latest approved patch-set and the submitted one.

    Change information

    Commit message:
    simd/internal/spec: fix ConvertToZ width rounding

    The current "zL=xL" constraint doesn't apply width rounding, so we
    don't get

    (Float64x2).ConverToFloat32() Float32x4

    This changes the constraint to z={zB}{zN}x{xL}, which does apply width
    rounding, so we do get the width-rounded method.
    Change-Id: I9248f858459aa83ec516f016e682506771ad7385
    Files:
    • M src/simd/internal/spec/converts.go
    • M src/simd/internal/spec/doc.go
    Change size: S
    Delta: 2 files changed, 11 insertions(+), 1 deletion(-)
    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: I9248f858459aa83ec516f016e682506771ad7385
    Gerrit-Change-Number: 828144
    Gerrit-PatchSet: 3
    Gerrit-Owner: Austin Clements <aus...@google.com>
    Gerrit-Reviewer: Austin Clements <aus...@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