Skip to content

Vector int64 +, -, *, % still round through double above 2^53 (div was fixed in #403) #412

Description

@singaraiona

Summary

#403 made integer div exact above 2^53, but the sibling ops in the same binary_range I64 arm still compute through double and round:

(+ [9007199254740993 -9007199254740993] [1 1])  ;; [9007199254740993 -9007199254740991] — want ...994 / ...992
(- [9007199254740993] [1])                       ;; 9007199254740991 — want ...992
(* [9007199254740993] [1])                       ;; 9007199254740992 — want ...993
(% [9007199254740993 9007199254740995] [3 3])    ;; [2 0] — want [0 2]
(div [9007199254740993] [3])                     ;; exact since #403

Identical in builds before and after #403 — not a regression, just the remaining chapter of the same story.

Notes

  • The fix(arith): keep integer div exact and UB-free #403 pattern transfers directly: an i64_span_dbl_exact (±2^53) gate keeping the vectorized double loop for the common case, an exact int64 kernel otherwise. For +/-/* the exact kernel needs overflow handling consistent with the atoms' existing convention (check what scalar + does at INT64_MAX today and match it).
  • When picking this up, also fold in the gate-scan cost lesson from fix(arith): keep integer div exact and UB-free #403's review: don't scan broadcast scalars per element, scan vector operands through typed pointers, fuse the operand passes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions