[FIRRTLFolds] AggOneShot is too conservative
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 524
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 46
Description
Currently AggOneShot is really conservative about the user of subindex/subfield and barely successes.
For example, `$ circt-opt -canonicalize` cannot optimize the IR below:
```
firrtl.circuit "Foo" {
firrtl.module @Foo(in %b: !firrtl.uint<1>, out %a: !firrtl.uint<2>) {
%foo = firrtl.wire : !firrtl.vector, 2>
%0 = firrtl.subindex %foo[1] : !firrtl.vector, 2>
%1 = firrtl.subindex %foo[0] : !firrtl.vector, 2>
firrtl.strictconnect %1, %b : !firrtl.uint<1>
firrtl.strictconnect %0, %b : !firrtl.uint<1>
%2 = firrtl.add %1, %0 : (!firrtl.uint<1>, !firrtl.uint<1>) -> !firrtl.uint<2>
firrtl.strictconnect %a, %2 : !firrtl.uint<2>
}
}
```
I would expect connections `firrtl.strictconnect %1, %b` and `firrtl.strictconnect %0, %b` are canonicalized into `firrtl.strictconnect %foo, (vectorcreate %b, %b))` but it is not optimized because `AggOneShot::getCompleteWrites` is really conservative about users of subelements.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the AggOneShot::getCompleteWrites entry point and reproduce the issue with circt-opt -canonicalize using the FIRRTL IR in the report. Trace why users of subindex and subfield prevent complete-write detection. Done means the two strictconnect operations are canonicalized into a vectorcreate-based connection, with the reported example covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100