circt
circt copied to clipboard
[Comb] or(concat, concat) -> concat & or(and, concat) -> concat(extract) canonicalizer
trafficstars
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
}