llvm / llvm/circt

[Comb] or(concat, concat) -> concat & or(and, concat) -> concat(extract) canonicalizer

Open
#8,260 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Comb enhancement
Dominant language
C++
Stars
2.2k
Forks
524
Avg merge
3d 2h
Merged PRs (30d)
46

Description

If I'm reading this right, there could be a set of comb canonicalizers doing the following simplification from

  hw.module @alias(in %init : i4, in %in0 : i1, in %in1 : i1, out out : i4) {
    %c0_i2 = hw.constant 0 : i2
    %false = hw.constant false
    %c-5_i4 = hw.constant -5 : i4
    %c-3_i4 = hw.constant -3 : i4
    %c0_i3 = hw.constant 0 : i3
    %c-2_i4 = hw.constant -2 : i4
    %0 = comb.and %init, %c-2_i4 : i4
    %1 = comb.concat %c0_i3, %in1 : i3, i1
    %2 = comb.or %1, %0 : i4
    %3 = comb.and %2, %c-3_i4 : i4
    %4 = comb.concat %c0_i2, %in0, %false : i2, i1, i1
    %5 = comb.or %4, %3 : i4
    %6 = comb.and %5, %c-5_i4 : i4
    %7 = comb.concat %false, %in1, %c0_i2 : i1, i1, i2
    %8 = comb.or %7, %6 : i4
    hw.output %8 : i4
  }

to

  hw.module @alias(in %init : i4, in %in0 : i1, in %in1 : i1, out out : i4) {
    %0 = comb.extract %init from 3 : (i4) -> i1
    %1 = comb.concat %0, %in1, %in0, %in1 : i1, i1, i1, i1
    hw.output %1 : i4
  }

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 tracing the existing comb.and, comb.or, comb.concat, and comb.extract canonicalization behavior in the CIRCT codebase; the issue does not name specific files or tests. Use the before-and-after MLIR examples to define done: the shown patterns should simplify to the equivalent extract-and-concat form.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.