DfgPeephole: Further restrict PUSH_REDUCTION_THROUGH_CONCAT
Only apply when there is guaranteed to be a subsequent constant folding and elimination of some of the expression, otherwise this sometimes interferes with the simplification of concatenations and harms overall performance.
This commit is contained in:
parent
1a8188e1b4
commit
22fcd616aa
|
|
@ -415,12 +415,12 @@ class V3DfgPeephole final : public DfgVisitor {
|
|||
}
|
||||
|
||||
if (DfgConcat* const concatp = srcp->cast<DfgConcat>()) {
|
||||
if (!concatp->hasMultipleSinks()) {
|
||||
if (concatp->lhsp()->is<DfgConst>() || concatp->rhsp()->is<DfgConst>()) {
|
||||
APPLYING(PUSH_REDUCTION_THROUGH_CONCAT) {
|
||||
// Reduce the parts of the concatenation
|
||||
Reduction* const lRedp = new Reduction{m_dfg, srcp->fileline(), m_bitDType};
|
||||
Reduction* const lRedp = new Reduction{m_dfg, concatp->fileline(), m_bitDType};
|
||||
lRedp->srcp(concatp->lhsp());
|
||||
Reduction* const rRedp = new Reduction{m_dfg, srcp->fileline(), m_bitDType};
|
||||
Reduction* const rRedp = new Reduction{m_dfg, concatp->fileline(), m_bitDType};
|
||||
rRedp->srcp(concatp->rhsp());
|
||||
|
||||
// Bitwise reduce the results
|
||||
|
|
@ -429,9 +429,10 @@ class V3DfgPeephole final : public DfgVisitor {
|
|||
replacementp->rhsp(rRedp);
|
||||
vtxp->replaceWith(replacementp);
|
||||
|
||||
// Optimize the new reductions
|
||||
// Optimize the new terms
|
||||
optimizeReduction(lRedp);
|
||||
optimizeReduction(rRedp);
|
||||
iterate(replacementp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,12 +149,12 @@ module t (
|
|||
`signal(PUSH_BITWISE_THROUGH_REDUCTION_AND, (&(rand_a + 64'd105)) & (&(rand_b + 64'd108)));
|
||||
`signal(PUSH_BITWISE_THROUGH_REDUCTION_OR, (|(rand_a + 64'd106)) | (|(rand_b + 64'd109)));
|
||||
`signal(PUSH_BITWISE_THROUGH_REDUCTION_XOR, (^(rand_a + 64'd107)) ^ (^(rand_b + 64'd110)));
|
||||
`signal(PUSH_REDUCTION_THROUGH_CONCAT_AND, &{(rand_a + 64'd102), rand_b});
|
||||
`signal(PUSH_REDUCTION_THROUGH_CONCAT_OR, |{(rand_a + 64'd103), rand_b});
|
||||
`signal(PUSH_REDUCTION_THROUGH_CONCAT_XOR, ^{(rand_a + 64'd104), rand_b});
|
||||
`signal(REMOVE_WIDTH_ONE_REDUCTION_AND, &{randbit_a ^ rand_a[0], rand_b});
|
||||
`signal(REMOVE_WIDTH_ONE_REDUCTION_OR, |{randbit_a ^ rand_a[1], rand_b});
|
||||
`signal(REMOVE_WIDTH_ONE_REDUCTION_XOR, ^{randbit_a ^ rand_a[2], rand_b});
|
||||
`signal(PUSH_REDUCTION_THROUGH_CONCAT_AND, &{1'd1, rand_b});
|
||||
`signal(PUSH_REDUCTION_THROUGH_CONCAT_OR, |{1'd1, rand_b});
|
||||
`signal(PUSH_REDUCTION_THROUGH_CONCAT_XOR, ^{1'd1, rand_b});
|
||||
`signal(REMOVE_WIDTH_ONE_REDUCTION_AND, &rand_a[0]);
|
||||
`signal(REMOVE_WIDTH_ONE_REDUCTION_OR, |rand_a[0]);
|
||||
`signal(REMOVE_WIDTH_ONE_REDUCTION_XOR, ^rand_a[0]);
|
||||
`signal(REMOVE_XOR_WITH_ZERO, 64'd0 ^ rand_a);
|
||||
`signal(REMOVE_XOR_WITH_ONES, -64'd1 ^ rand_a);
|
||||
`signal(REPLACE_COND_DEC, randbit_a ? rand_b - 64'b1 : rand_b);
|
||||
|
|
|
|||
Loading…
Reference in New Issue