Support reduction or in constraints (#6840)

This commit is contained in:
Pawel Kojma
2025-12-19 12:37:20 -05:00
committed by GitHub
parent 47d1a50aa4
commit 5244766b7b
2 changed files with 19 additions and 0 deletions
+12
View File
@@ -1050,6 +1050,18 @@ class ConstraintExprVisitor final : public VNVisitor {
VL_DO_DANGLING(nodep->deleteTree(), nodep);
iterate(sump);
}
void visit(AstRedOr* nodep) override {
if (editFormat(nodep)) return;
// Convert to (x != 0)
FileLine* const fl = nodep->fileline();
AstNodeExpr* const argp = nodep->lhsp()->unlinkFrBack();
V3Number numZero{fl, argp->width(), 0};
AstNodeExpr* const neqp = new AstNeq{fl, argp, new AstConst{fl, numZero}};
neqp->user1(true);
nodep->replaceWith(neqp);
VL_DO_DANGLING(nodep->deleteTree(), nodep);
iterate(neqp);
}
void visit(AstNodeBiop* nodep) override {
if (editFormat(nodep)) return;
editSMT(nodep, nodep->lhsp(), nodep->rhsp());