Skip to content

[LLHD] Deseq mistakenly marks icmp ne %false, %false as poison #8512

Closed
@fabianschuiki

Description

@fabianschuiki

Consider the following input:

hw.module @Foo(in %clk: i1, in %d: i7) {
  %0 = llhd.constant_time <0ns, 1d, 0e>
  %c0_i7 = hw.constant 0 : i7
  %true = hw.constant true
  %false = hw.constant false
  %q = llhd.sig %c0_i7 : i7
  %1:2 = llhd.process -> i7, i1 {
    cf.br ^bb1(%clk, %c0_i7, %false : i1, i7, i1)
  ^bb1(%2: i1, %3: i7, %4: i1):  // 4 preds: ^bb0, ^bb2, ^bb3, ^bb3
    llhd.wait yield (%3, %4 : i7, i1), (%clk : i1), ^bb2(%2 : i1)
  ^bb2(%5: i1):  // pred: ^bb1
    %6 = comb.xor bin %5, %true : i1
    %7 = comb.and bin %6, %clk : i1
    cf.cond_br %7, ^bb3, ^bb1(%clk, %c0_i7, %false : i1, i7, i1)
  ^bb3:  // pred: ^bb2
    %8 = comb.icmp ne %false, %false : i1
    %9 = comb.icmp ne %true, %true : i1
    %10 = comb.xor %8, %9 : i1
    cf.cond_br %10, ^bb1(%clk, %c0_i7, %true : i1, i7, i1), ^bb1(%clk, %d, %true : i1, i7, i1)
  }
  llhd.drv %q, %1#0 after %0 if %1#1 : !hw.inout<i7>
}

Running this through circt-opt --llhd-deseq --debug-only=llhd-deseq produces the following:

- Analyzing llhd.drv %q, %1#0 after %0 if %1#1 : !hw.inout<i7>
- Boolean %true: true
- Successor boolean ^bb3#succ0 -> ^bb1#arg2 = true
- Block condition ^bb2: true
- Boolean %6: !a1
- Boolean %7: !a1&a2
- Successor condition ^bb2#succ0 -> ^bb3 = !a1&a2
- Block condition ^bb3: !a1&a2
- Boolean %false: false
- Boolean %8: poison
- Boolean %9: poison
- Boolean %10: poison
- Successor condition ^bb3#succ0 -> ^bb1 = poison
- Boolean %4: poison
- Aborting loc("debug.mlir":21:3): poison condition

The values %8, %9, and %10 get mistakenly marked as poison values. Only operations on the triggers (%clk in this case) should have their value poisoned if the Deseq pass does not support mapping them to a truth table.

Metadata

Metadata

Assignees

No one assigned

    Labels

    LLHDbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions