Skip to content

mig_inv_propagation crashes if PO is connected to a complement of PI #693

@uenoku

Description

@uenoku

Describe the bug
What went wrong? (e.g. the optimized circuit was not equivalent to the original one, an assertion failed, etc.)
mig_inv_propagation crashes with out-of-bounds access when PO is derived by a complement of PI. I believe this part needs to skip non-MIG node (since invert-node assumes that node is a MIG node).

if ( ntk.is_complemented( f ) )
{
// if it is complemented, invert the node
auto const old_node = ntk.get_node( f );
auto const new_node = invert_node( old_node );

To Reproduce
Steps to reproduce the behavior:

  1. Which version of mockturtle (commit or PR number) are you using? (Preferably the latest, unless there are special reasons.)
    latest(9f3a6c9)

  2. A complete snippet of your code (usually a cpp file including main).

#include <mockturtle/algorithms/mig_inv_propagation.hpp>
#include <mockturtle/networks/mig.hpp>
#include <iostream>

mockturtle::mig_network build_Foo() {
  mockturtle::mig_network ntk;
  auto a = ntk.create_pi();
  ntk.create_po(!a);
  return ntk;
}

int main() {
  auto ntk = build_Foo();
  mockturtle::mig_inv_propagation(ntk);
  std::cout << "after mig_inv_propagation: gates=" << ntk.num_gates() << '\n';
  return 0;
}
  1. The benchmark circuit for which the error occurs. Please try to minimize it first by using the testcase minimizer (docs, example code).
    It was found in random test case.
  2. Error messages or print-outs you see (if any) (preferably copy-pasted as-is).

Environment

  • OS: Linux
  • Compiler: clang 20
  • Compilation mode: DEBUG

Additional context
Add any other context about the problem here.

Check list

  • I have tried to run in DEBUG mode and there was no assertion failure (or the reported bug is an assertion failure).
  • I have made sure that the provided code compiles and the testcase reproduces the error.
  • I have minimized the testcase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions