Hoist multiple bitslices above operations
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 283
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 135
Description
Bitslices are hoisted above some operations if the bitslice is the only use of the operation. Here is the code which hoists slices above selects:
https://github.com/google/xls/blob/ffb0f496526ad036fe97c47ffed1abfc1bfa495f/xls/passes/bit_slice_simplification_pass.cc#L285
It's also possible to hoist bitslices above such operations if there is are multiple bitslices which slice out a subset of the bits from the operation. Example:
```
s: bits[32] = sel(p, cases=[a, b])
bs0: bits[4] = bit_slice(s, start=5, width=4)
bs1:bits[3] = bit_slice(s, start=7, width=3)
```
Might be transformed to:
```
a_narrowed: bits[5] = bit_slice(a, start=5, width=5)
b_narrowed: bits[5] = bit_slice(b, start=5, width=5)
s_narrowed = sel(p, case=[a_narrowed, b_narrowed])
bs0: bits[4] = bit_slice(s_narrowed, start=0, width=4)
bs1: bits[3] = bit_slice(s_narrowed, start=2, width=3)
```
The advantage is the narrower select and the opportunity to further narrow the upstream operations (`a` and `b`).
Contributor guide
Assessment
This issue has not been assessed yet.