llvm / llvm/circt

[Comb] Fold concat-with-constant into the arms of a mux that has constant operands

Open
#1,572 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

good first issue HW
Dominant language
C++
Stars
2.2k
Forks
524
Avg merge
3d 2h
Merged PRs (30d)
46

Description

This IR:

```
hw.module @SevenSegmentDecoder(%in: i4) -> (%out: i7) {
%c1_i4 = hw.constant 1 : i4
%c6_i6 = hw.constant 6 : i6
%c-1_i6 = hw.constant -1 : i6
%false = hw.constant false
%0 = comb.icmp eq %in, %c1_i4 : i4
%1 = comb.mux %0, %c6_i6, %c-1_i6 : i6
%2 = comb.concat %false, %1 : (i1, i6) -> i7
hw.output %2 : i7
}
```

Can be simplified by folding the "concat of constant + mux" into the two arms of the mux. This should be profitable if the mux has at least one constant operand.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Comb folding or canonicalization entry points for comb.concat and comb.mux, then reproduce the supplied IR example. Check how constant operands are represented and how the mux arms can receive the concat operation. Done means the example is simplified by folding the concatenation into the mux arms when at least one mux operand is constant, with coverage for the transformation.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.