Skip to content

Tags

Tags

v0.0.0-11323-ge60aaf538

Toggle v0.0.0-11323-ge60aaf538's commit message
xls/data_structures: Add snapping support to BinarySearch helpers.

Callers whose monotonic predicate produces a concrete witness tighter than the probed point (such as an achieved minimum delay from a feasible schedule) previously had to bisect through values already known to satisfy the condition. Adding snapping support to the standard binary search helpers lets those callers jump directly to the witness bound while preserving worst-case O(log N) termination.

* Overload `BinarySearchMaxTrue`, `BinarySearchMinTrue`, and their `*WithStatus` variants (constrained via C++20 `requires` to avoid `bool`-to-`std::optional<int64_t>` ambiguity) to accept callbacks returning `std::optional<int64_t>` / `absl::StatusOr<std::optional<int64_t>>`, where `std::nullopt` means false and a returned value `v` means true with known-true witness `v` (`v >= i` for max, `v <= i` for min).
* Route the existing `bool` and `StatusOr<bool>` functions through the shared snapping implementation, validate witness direction and monotonicity via `XLS_RET_CHECK`, handle witnesses past `[start, end]` without extra endpoint probes, and use `std::midpoint` for overflow-free bisection.

Co-authored-by: XLS Team <xls-github-bot@google.com>
PiperOrigin-RevId: 1035715219

v0.0.0-11318-gcc12d8307

Toggle v0.0.0-11318-gcc12d8307's commit message
Fix super-linear LLVM compile time for counted_for with large loop st…

…ate in the JIT.

`HandleCountedFor` loaded and stored the entire loop state as an LLVM
first-class aggregate value: once when initializing the state buffer and
once per iteration when copying the next state back into the state buffer.
LLVM scalarizes such aggregate loads/stores element-by-element (InstCombine
unpacks every struct and any array of up to 1024 elements, recursively; SROA
unpacks aggregate loads/stores of allocas with no size limit), producing one
instruction (or `insertvalue`) per array element. Subsequent passes
(SLPVectorizer, InstCombine, GVN) and the backend then run in super-linear
time and memory on the result. For a `counted_for` whose state is e.g.
`(token, bits[1], bits[64][20480])` this made `aot_compiler_main` take
minutes and tens of GiB of memory on otherwise trivial unoptimized IR.

Hold the loop state in two buffers that are ping-ponged between iterations
instead: the body reads from one buffer and writes the next state into the
other, with the two pointers carried across iterations as loop-carried phis
and swapped on every iteration. The state is only ever moved with `memcpy`
(into the first buffer before the loop and out of the final buffer after
it). This also removes the full copy of the state (and, for states larger
than the stack alloca limit, a heap allocation and free) on every iteration,
resolving a long-standing TODO.

Measured with `aot_compiler_main` on a proc whose `counted_for` state is a
tuple wrapping a `bits[64][4096]` array updated at a dynamic index on each
of 15 iterations: 8.05 s / 1.48 GB before, 0.04 s / 53 MB after. A
`bits[64][1024][9]` state updated at a dynamic row index: 20.4 s before,
4.1 s after (the remainder is the per-element packed-ABI wrapper, which is
unrelated to `counted_for`).

Add an evaluator test with a large (heap-buffered), tuple-wrapped array loop
state updated at a dynamic index, covering trip counts of zero, one, and
both parities, so that both orientations of the ping-pong buffers and the
zero-trip path are exercised under both the interpreter and the JIT.

PiperOrigin-RevId: 1035047228

v0.0.0-11300-gf77a9b32e

Toggle v0.0.0-11300-gf77a9b32e's commit message
Narrow shift amounts with redundant leading sign bits in NarrowingPass.

Shift amounts that come from `sign_ext` (or selects over sign-extended and zero-extended values) are not narrowed by leading-zero analysis because their upper bits are only known to match the sign bit, leaving narrow-data shifts with wide shift amounts in optimized IR.

Strip redundant leading sign bits from shift amounts in `shll`, `shrl`, and `shra` down to `max(amt_width - leading_signs + 1, ceil(log2(data_width)) + 1)` when narrower than the leading-zero bound. Non-negative shift amounts drop only zero bits and keep the exact same value; negative shift amounts retain a set MSB with weight at least `data_width`, so both original and narrowed amounts saturate identically (zero for `shll`/`shrl`, sign-fill for `shra`).

PiperOrigin-RevId: 1033976144

v0.0.0-11289-g36a22e9b8

Toggle v0.0.0-11289-g36a22e9b8's commit message
Automated Code Change

PiperOrigin-RevId: 1033151275

v0.0.0-11263-g753a8f12a

Toggle v0.0.0-11263-g753a8f12a's commit message
Pass std::string to riegeli::FdReader and FdWriter in XLS tests.

`xls/tools/trace_to_perfetto_test.cc` and `xls/interpreter/tracing_observer_test.cc` pass `std::filesystem::path` directly to `riegeli::FdReader` and `riegeli::FdWriter`. Call `.string()` explicitly so they remain compatible when Riegeli removes `PathInitializer` in favor of `absl::string_view`.

PiperOrigin-RevId: 1031237430

v0.0.0-11261-g6081a2aec

Toggle v0.0.0-11261-g6081a2aec's commit message
Fix wiring of 2D io object arrays.

When a proc bound a 2D `Source`/`Sink` array element by element, each child got
the wrong elements: a column instead of its row. For example, with
`to_child: Sink<u32>[2][2]` and child `i` bound to `to_child[i]`:

```
before: child 0 gets _to_child__0_0, _to_child__1_0
after:  child 0 gets _to_child__0_0, _to_child__0_1
```

The elements were matched to channels in a different order than the channels
were named. Both now use the same order.

PiperOrigin-RevId: 1030245716

v0.0.0-11258-ge27ef1ee5

Toggle v0.0.0-11258-ge27ef1ee5's commit message
xls/dslx/ir_convert: Migrate ir_converter_options_flags.proto to Edit…

…ions 2023 with explicit defaults

`IrConverterOptionsFlagsProto` previously used `syntax = "proto3"`, so all
non-zero boolean defaults (`verify`, `warnings_as_errors`,
`lower_to_proc_scoped_channels`, `emit_trace`, `emit_cover`, `emit_assert`)
were duplicated across `ir_converter_options_flags.cc`, `ConvertOptions`, and
`ir_converter_main.cc`. Passing an empty or partial proto silently disabled
verification, warnings-as-errors, traces, covers, and asserts.

Default value impact:
- CLI flag defaults: `--lower_to_proc_scoped_channels` `ABSL_FLAG` default
  changes from `false` to `true` to match `ConvertOptions` and existing runtime
  behavior (it is only populated via `POPULATE_FLAG_IF_SPECIFIED`, so
  unspecified already ran with `true`). All other `ABSL_FLAG` defaults keep
  their exact prior values.
- Proto defaults: `IrConverterOptionsFlagsProto` now carries explicit non-zero
  defaults matching the CLI flags and `ConvertOptions` (`verify=true`,
  `warnings_as_errors=true`, `lower_to_proc_scoped_channels=true`,
  `emit_trace=true`, `emit_cover=true`, `emit_assert=true`).
  `dslx_stdlib_path` intentionally stays without an explicit proto default
  because `kDefaultDslxStdlibPath` differs across build environments.
- C++ defaults: unchanged (`ConvertOptions` remains a literal/constexpr type;
  unit tests now assert parity with
  `IrConverterOptionsFlagsProto::default_instance()`).

Changes:
- Migrate `xls/dslx/ir_convert/ir_converter_options_flags.proto` to
  `edition = "2023"` with explicit `[default = true]` annotations.
- Derive boolean `ABSL_FLAG` defaults in
  `xls/dslx/ir_convert/ir_converter_options_flags.cc` from
  `IrConverterOptionsFlagsProto::default_instance()`.
- Simplify `lower_to_proc_scoped_channels` reading and fall back to
  `kDefaultDslxStdlibPath` when `dslx_stdlib_path` is unset in
  `xls/dslx/ir_convert/ir_converter_main.cc`.
- Add parity and `--ir_converter_options_proto` fallback unit tests in
  `xls/dslx/ir_convert/ir_converter_options_flags_test.cc` and
  `xls/dslx/ir_convert/ir_converter_main_test.py`.
PiperOrigin-RevId: 1029590845

v0.0.0-11232-g91bf81770

Toggle v0.0.0-11232-g91bf81770's commit message
Support decoupled proc state access in IR optimization passes.

Several IR optimization passes assumed coupled proc state lowering, where every
state element has a `StateRead` and every `Next` pairs with one. Under that
assumption, `ArrayUntuplePass` and `ProcStateNarrowingPass` skipped or failed on
zero-read state elements. `CanonicalizationPass` also kept always-false
`StateRead`s alive, while `ConditionalSpecializationPass` intersected
`StateRead` access conditions with `Next` predicates.

Support zero-read state elements in `ArrayUntuplePass` and
`ProcStateNarrowingPass`. Add `decouple_state_access` to
`OptimizationPassOptions` and `opt_main`, defaulting to false until Codegen
v1.5 scoreboarding lands. When enabled, `CanonicalizationPass` removes
always-false `StateRead`s. `ConditionalSpecializationPass` also specializes
`StateRead` predicates strictly from data uses, independent of pre-legalization
`eliminate_noop_next` cleanup.

PiperOrigin-RevId: 1028563699

v0.0.0-11217-gdb882ead6

Toggle v0.0.0-11217-gdb882ead6's commit message
Automated Code Change

PiperOrigin-RevId: 1027628634

v0.0.0-11216-gb16df3eda

Toggle v0.0.0-11216-gb16df3eda's commit message
Update SelectSimplificationPass and SelectRangeSimplificationPass doc…

…umentation comment.

Refresh the Gemini-generated C++ header comment in `select_simplification_pass.h` for `SelectSimplificationPass` and `SelectRangeSimplificationPass` to reflect its current implementation, and regenerate the pass documentation Markdown.

PiperOrigin-RevId: 1027412303