Skip to content

ENG-1889#5

Merged
akashlevy merged 2 commits intoyosys-experimentalfrom
ENG-1889
Apr 11, 2026
Merged

ENG-1889#5
akashlevy merged 2 commits intoyosys-experimentalfrom
ENG-1889

Conversation

@AdvaySingh1
Copy link
Copy Markdown

No description provided.

@linear
Copy link
Copy Markdown

linear bot commented Apr 10, 2026

ENG-1889

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 10, 2026

Greptile Summary

This PR replaces an assert in Gia_ManAppendAnd that fired when both literals referenced the same variable with a graceful handler that reclaims the appended object and returns the simplified result (x & x = x, x & !x = 0).

  • The --p->nObjs reclamation does not roll back the Vec_IntPush(&p->vHash, 0) that Gia_ManAppendObj performs when structural hashing is active, leaving p->vHash permanently one entry ahead of p->nObjs and corrupting hash lookups for all subsequently appended nodes.

Confidence Score: 3/5

Not safe to merge as-is — the missing vHash rollback silently corrupts structural hashing for all subsequent AND nodes when a degenerate AND is encountered.

A P1 correctness bug exists: the object-count decrement (--p->nObjs) is not paired with Vec_IntPop(&p->vHash), leaving the hash vector out-of-sync. This desynchronisation causes incorrect hash slot assignments for every node appended after a degenerate AND is detected.

src/aig/gia/gia.h — specifically the early-return block in Gia_ManAppendAnd around lines 733–737.

Important Files Changed

Filename Overview
src/aig/gia/gia.h Replaces a same-variable literal assertion in Gia_ManAppendAnd with a graceful handler, but the --p->nObjs reclamation omits the matching Vec_IntPop(&p->vHash) rollback, leaving p->vHash out-of-sync when structural hashing is active.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["Gia_ManAppendAnd(p, iLit0, iLit1)"] --> B["Gia_ManAppendObj(p)\n• vHash.push(0) if hashing active\n• return pObjs[nObjs++]"]
    B --> C{assertions pass?}
    C -- No --> FAIL[abort]
    C -- Yes --> D{"!fGiaSimple &&\nLit2Var(iLit0)==Lit2Var(iLit1)?"}
    D -- Yes --> E["print WARNING\n--p->nObjs  ⚠️ vHash NOT popped"]
    E --> F{iLit0 == iLit1?}
    F -- Yes --> G["return iLit0\n(x & x = x)"]
    F -- No --> H["return 0\n(x & !x = false)"]
    D -- No --> I["fill pObj fields\n(iDiff0/1, fCompl0/1)"]
    I --> J["handle pFanData / fSweeper / fBuiltInSim"]
    J --> K["return Gia_ObjToLit(p, pObj)"]
Loading

Reviews (1): Last reviewed commit: "ENG-1889" | Re-trigger Greptile

Comment thread src/aig/gia/gia.h
Comment thread src/aig/gia/gia.h
@akashlevy akashlevy merged commit 223d685 into yosys-experimental Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants