Skip to content

Fix missing/superfluous dependencies. - #4790

Closed
hzeller wants to merge 46 commits into
google:mainfrom
hzeller:feature-20260816-fix-deps
Closed

hzeller wants to merge 46 commits into
google:mainfrom
hzeller:feature-20260816-fix-deps

Conversation

@hzeller

@hzeller hzeller commented Aug 16, 2026

Copy link
Copy Markdown
Member

Application of:

source <(xls/dev_tools/run-build-cleaner.sh ...)

Application of:

```
source <(xls/dev_tools/run-build-cleaner.sh ...)
```
xls-github-bot and others added 27 commits August 22, 2026 16:22
PiperOrigin-RevId: 965930602
…ges.

Some LLM agents recently tried to fix optimization bugs by smuggling data between passes/invocations of passes using the SharedNodeData to store shared state.

This is not a behavior we want to allow. SharedNodeData is purely a performance optimization and the NodeData held within it must always be fully recreatable at any point.

Add a note to the documentation to clue agents in on the fact that stashing data in this location is forbidden.

PiperOrigin-RevId: 965979295
…rrowing_pass.cc

Bit width is narrowed to the smallest bit width needed to cover every value it can reach.

PiperOrigin-RevId: 966037841
Now, we can separately determine the case values for the LUT select before it gets merged into child selects. This will allow us to perform transforms outside of merge select, including building a new select node out of the case values.

Unfortunately the query engine populated during candidate filtering still needs to be used during case value determination when looking at Node known values, so there is still some required coupling between the two methods.

PiperOrigin-RevId: 966040436
strength reduction.

Previously, StrengthReductionPass split adders and subtractors at a
single non-propagating carry/borrow bit per pass iteration. For
operations with large bit widths (e.g., bits[1593]), chipping away
narrow bit slices iteratively caused hundreds of fixed-point
optimization pass cycles, resulting in fuzzer timeouts.

This change updates the adder and subtractor strength reduction to collect
all non-propagating carry/borrow split points in a single pass and split
the binary operation into multiple sub-adders/sub-subtractors
simultaneously via SplitBinOp.

Fixes google#4411

PiperOrigin-RevId: 966092726
Eliminate `caller_or_target_struct_context` and make it more clear which
context is required for each usage.

PiperOrigin-RevId: 966168451
Also specifically tell it to be always strictly following
only positively active ifdef branches.
For Python, we extract the golden-file testing utilities into a common Python library, and update the golden-file updating script to identify tests that use it.

We also add automatic sha256sum updating capabilities to the `check_sha256sum_test` and `check_sha256sum_frozen` Bazel rules by generating an update target that uses buildozer, and (similar to `diff_test`) update `rebuild_golden_files.sh` to use these capabilities.

PiperOrigin-RevId: 966197865
Fixes an issue in codegen v1.5 where I/O flops gated the upstream ready signal on the incoming valid, creating unnecessary combinational paths & suppressing ready signaling unnecessarily while waiting. Flop ready is now decoupled from valid.

Also fixes an issue where kValidData channels with input flops could get stuck with their flops not draining properly.

For simplicity, we unify the I/O commit logic (based on `stage_done` signals), making it easier to `GetOrCreateStageDone` signals to avoid accidental duplication.

PiperOrigin-RevId: 966633857
Because these functions are now parametric, add a new DSLX file that exports non-parametric variants for the various tests that rely on being able to directly IR convert these functions.

PiperOrigin-RevId: 966715063
This change introduces JitStoredValue to represent JIT inputs and outputs as either a Node or a StateElement, decoupling state tracking from specific StateRead nodes. This enables support for predicated StateRead operations in the JIT, which now generate LLVM IR to conditionally select a dummy value when the predicate is false. Additionally, ProcBuilder::StateElement now defaults its non_synthesizable argument to false, and a new test case has been added to verify decoupled state reads.

PiperOrigin-RevId: 966717990
ReplaceImplicitUsesWith, when invoked on one of the stage control signals on scheduled block IR, previously accepted any node & just tried to force it into the correct stage.

Now, we check & return an error if the node provided is scheduled but not in the right stage.

PiperOrigin-RevId: 966837164
If a fuzz test gives an absurdly large number of stages the test may run out of memory which is not an error we really want to spend effort checking for.

This limits the pipeline_stages field to a range of 0 to 1000 in the fuzztest domain to prevent generating excessively large pipeline depths.

PiperOrigin-RevId: 966844838
Our proto-based pipeline specifications already allow fixed-point execution, but it's currently ignored; this will now work correctly.

PiperOrigin-RevId: 966854756
PiperOrigin-RevId: 967242909
If we run CSE on scheduled IR, it should respect that equivalent expressions in distinct stages should not be merged.

This will let us include CSE in some experiments with basic post-scheduling optimizations in codegen.

PiperOrigin-RevId: 967275650
…tion_pass.cc

When creating next nodes for non-synth, if the update is a pass-through or NoOp, find the matching non-synth state read by predicate.

Add an ir_matcher for state_reads with predicates

PiperOrigin-RevId: 967279840
…ple_flattening_pass.cc

Store `AbstractStateRead` structs inside `AbstractStateElement`. `AbstractStateRead` records the predicate, label, and a temporary placeholder literal for each decomposed state read. Once the original state element state_read and next_value nodes are cleaned up, rebuild the proc state. For each flattened state element create new state_read's using the stored `AbstractStateRead` entries.

PiperOrigin-RevId: 967413474
PiperOrigin-RevId: 967422497
Updates LLVM usage to match
[fdb39b1112a6](llvm/llvm-project@fdb39b1112a6)

PiperOrigin-RevId: 967568103
- Clone the non-state-wrapped type for struct members.
- Preserve the `use_wrapped_type_if_proc_state` flag in MemberTypeAnnotation.
- Avoid cloning external AST nodes in CloneModuleRemovingMembers to preserve pointer identity. We looked into expanding this feature to other Clone* functions as well but shelved it temporarily.

PiperOrigin-RevId: 967817610
Next nodes are no longer constructed with state reads. This refactors `m::Next` and `m::NextWithLabel` to match against `StateElement*` or state element name, value, optional predicate, and optional label.

Replaces all usages of `m::NextWithStateElement` and `m::NextWithStateElementWithLabel` with `m::Next` and `m::NextWithLabel`.

PiperOrigin-RevId: 967892986
By managing this separately, we can clean up our code. We were previously overloading this signal onto `outputs_valid`, causing significant confusion & complicating some upcoming improvements.

This of course required updating our flow-control logic in Codegen 1.5, as well as our ScheduledBlock IR parsing logic.

PiperOrigin-RevId: 967904645
For numbers, don't print the type of the array dimension.

PiperOrigin-RevId: 967952666
analysis.

If a member was already annotated as `State`, this was leading to
double-wrapping (e.g., `State<State<T>>`).

So in `ProcStateVisitor::HandleProcDef`, check if the member's type
annotation is a `TypeRefTypeAnnotation` that resolves to the builtin
`State` struct definition, and skip wrapping if so.

PiperOrigin-RevId: 967958522
scampanoni and others added 18 commits August 22, 2026 16:22
This change adds the ability to collapse a chain of heterogeneous select nodes (composed of Select, PrioritySelect, and OneHotSelect) into a single OneHotSelect.

This is achieved by generalizing the existing logic within the BDD simplification pass, which previously only collapsed chains of standard Select nodes.

This change also extracts this transformation from the BDD simplification pass to its own pass.
The new pass, called collapse select chains pass, is invoked towards the end of the optimization pipeline to avoid blocking the analyses that tend to be more accurate with simple select nodes.

PiperOrigin-RevId: 967966663
text of the transformed module back through the type checker, in a new
helper function.

PiperOrigin-RevId: 967984614
…ate_legalization_pass.cc.

To support multiple state reads:
* Generate a mutex assertion for `StateRead` nodes to verify at most one `StateRead` is active for a state element
* Generate write-without-read assertions that a `Next` node can only fire when at least one `StateRead` is active
* If there are no explicit next nodes for a `StateRead`, generate a default `Next` node
* If there are explicit next nodes, generate a default next value node for each `StateRead` when there are no explicit `Next` nodes active and the corresponding read's predicate is active. This helps preserve state when no explicit next fires.
* Loop through all `StateRead` nodes in order to ensure the pass is idempotent by not creating default `Next` nodes when they exist.

PiperOrigin-RevId: 967998228
"promote" local variables in a function-based test to an impl-based proc
field.

PiperOrigin-RevId: 968009577
…ameter to indicate negation

`is_signed` can be determined from the `to` node. The new out parameter lets a consumer understand if the coercion involved 2nd operand negation for applicable operations.

PiperOrigin-RevId: 968158867
Fix `FfiDelayEstimator` to retrieve `delay_ps` from the callee function being
invoked rather than the caller/enclosing function and add unit tests.

PiperOrigin-RevId: 968481489
DefaultHandler. Refactor most uses of AstNodeWithDefaultVisitor to use
it instead.

PiperOrigin-RevId: 968484973
PiperOrigin-RevId: 968493332
For each receive, we decouple the ready signal from that receive's own input valid signal, driving it instead by `inputs_valid & (all other active inputs are valid) & outputs_ready & active_outputs_ready`. This requires generating all-except-one conjunctions for the receive-valid conditions in each stage, which we do efficiently using a Brent-Kung-style two-sweep construction.

PiperOrigin-RevId: 968636449
…h.cc

Add unit tests to verify graph construction with multiple `StateRead` nodes:
* `ScheduleGraph::Create` correctly creates R * W backedges are created per state element where R are reads and W are writes and that node predecessors and successors are populated correctly.

* `ScheduleGraph::CreateSynchronousGraph` verify that the total of backedges is sum(R*W), and cross-proc channel predecessors and successors are linked correctly, and that `is_live_in` and `is_live_out` flags are set accurately for top-level interface channels.

PiperOrigin-RevId: 968637243
* dslx: reject duplicate match alternatives with both source locations

## Summary

- Reject duplicate match patterns even when an occurrence is embedded in a `|`-separated alternative.
- Highlight both the original and duplicate source locations in the compiler error.
- Preserve valid grouped alternatives and existing duplicate-arm checks.
- Preserve a disabled regression for the separate pre-existing case where an enum type alias gives the same variant two spellings.

## Problem Solved

DSLX compared complete match arms when checking for duplicates. Consequently, an enum variant could appear in separate arms and the match would still compile:

```dslx
match value {
  E::A => u32:0,
  E::B | E::A => u32:1,
  E::C => u32:2,
}
```

The second `E::A` can never match, hiding unreachable code and copy-and-paste mistakes. This change rejects the program with a `TypeInferenceError` and reports both occurrences.

## Implementation

Track individual top-level match alternatives alongside the existing whole-arm duplicate check. Retain the first occurrence so the error can name its location and attach both source spans to the diagnostic.

Programs that previously compiled with duplicate exact match alternatives now intentionally fail compilation. Valid grouped alternatives and existing range or tuple overlap behavior remain unchanged.

Enum type aliases such as `type Alias = E;` can still spell the same member as `E::A` and `Alias::A`. That pre-existing semantic-equivalence case is intentionally not fixed here; a repository-conventional `DISABLED_` regression records the failing behavior for future work.

## Testing

- `bazel test //xls/dslx/type_system_v2:typecheck_module_v2_control_flow_test //xls/dslx/exhaustiveness:exhaustiveness_match_test //xls/dslx/type_system:typecheck_module_test`
- Regression coverage verifies both source spans, rejects the reported enum pattern, and accepts unique grouped alternatives.
- Direct compiler checks cover the checked-in diagnostic fixture, existing whole-arm duplicates, and non-exhaustive enum matches.
- Forcing `DISABLED_MatchEnumVariantDuplicatedThroughTypeAlias` to run with `--gtest_also_run_disabled_tests` fails as expected; normal execution passes 100 control-flow tests and reports one disabled test.

* dslx: explain unresolved duplicate enum-alias match cases

E::A and Alias::A denote the same enum member after type Alias = E,
but match validation compares source spellings and incorrectly accepts
an unreachable duplicate arm.

Record beside the disabled regression that fixing this requires
resolving enum-member identity before comparing match patterns.
To allow google#4817 to be rebased.

PiperOrigin-RevId: 968755784
This change introduces several optimizations to `BddQueryEngine` and `BinaryDecisionDiagram` to avoid creating unnecessary BDD nodes and bypass expensive operations:
- Adds a `MutuallyExclusive` helper to check if two BDD nodes are mutually exclusive without constructing new BDD nodes.
- Enable early-exit for `KnownValue`, `IsAllZeros`, `IsAllOnes`, and `IsFullyKnown` by querying BDD nodes directly, rather than constructing a ternary.
- Optimizes `KnownEquals` and `KnownNotEquals` to use direct BDD index comparison when no assumption is present.
- Refactors `AtMostOneTrue` and `AtLeastOneTrue` to minimize BDD operations and handle untracked bits more efficiently.
- Skips redundant bounds checks (e.g., zero lower bounds or maximal intervals) during interval specialization.

Also takes advantage of the new MutuallyExclusive helper in the visibility analysis.

PiperOrigin-RevId: 968839585
For each receive, we decouple the ready signal from that receive's own input valid signal, driving it instead by `inputs_valid & (all other active inputs are valid) & outputs_ready & active_outputs_ready`. This requires generating all-except-one conjunctions for the receive-valid conditions in each stage, which we do efficiently using a Brent-Kung-style two-sweep construction.

PiperOrigin-RevId: 968845811
The new MergeRegistersPass identifies & merges registers in a block with identical types, reset values, and writes; it's controlled by the existing merge-strategy codegen option.

PiperOrigin-RevId: 968850047
Application of:

```
source <(xls/dev_tools/run-build-cleaner.sh ...)
```
@hzeller

hzeller commented Aug 22, 2026

Copy link
Copy Markdown
Member Author

I think I messed up this PR while rebasing. Will close and re-open afresh.

@hzeller hzeller closed this Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.