google / google/xls

[enhancement] opt should narrow adds where one operand has known leading/trailing zeros

Open
#3,123 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

### What's hard to do? (limit 100 words)

If we add two values `lhs + rhs` where `rhs` has (say) 3 trailing zeros, this can actually be simplified to `(lhs[3:] + rhs[3:]) ++ lhs[0:3]`.

XLS doesn't currently carry out these sorts of optimizations, which limits its ability to model the delay of these additions accurately, even if we would expect logic synthesis tools to spot & implement these adder optimizations.

### Current best alternative workaround (limit 100 words)

Users can manually optimize their code in these patterns, which is not ideal & risks correctness of their code

### Your view of the "best case XLS enhancement" (limit 100 words)

XLS would identify & optimize these opportunities, much as it does for addition where both operands have leading zeros.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.