Skip to content

Commit

Permalink
[MooreToCore] Ignore ConstantLike values in wait op (#7540)
Browse files Browse the repository at this point in the history
Skip values defined by `ConstantLike` ops when collecting the list of
values to observe in `llhd.wait` ops. Constants will never cause an
`llhd.wait` to resume execution since they never change value.
  • Loading branch information
fabianschuiki authored Aug 21, 2024
1 parent 5d8cf69 commit aae37b7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/Conversion/MooreToCore/MooreToCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ static void getValuesToObserve(Region *region,
for (auto value : operation->getOperands()) {
if (region->isAncestor(value.getParentRegion()))
continue;
if (auto *defOp = value.getDefiningOp();
defOp && defOp->hasTrait<OpTrait::ConstantLike>())
continue;
if (!alreadyObserved.insert(value).second)
continue;

Expand Down
3 changes: 1 addition & 2 deletions test/Conversion/MooreToCore/basic.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,6 @@ moore.module @WaitEvent() {
moore.return
}

// CHECK: [[FALSE:%.+]] = hw.constant false
// CHECK: [[PRB_A:%.+]] = llhd.prb %a
// CHECK: [[PRB_B:%.+]] = llhd.prb %b
// CHECK: llhd.process {
Expand All @@ -703,7 +702,7 @@ moore.module @WaitEvent() {
// CHECK: llhd.prb %b
// CHECK: cf.br ^[[BB2:.+]]
// CHECK: ^[[BB2]]:
// CHECK: llhd.wait ([[FALSE]], [[PRB_A]], [[PRB_B]] : {{.*}}), ^[[BB1]]
// CHECK: llhd.wait ([[PRB_A]], [[PRB_B]] : {{.*}}), ^[[BB1]]
%1 = moore.conditional %cond : i1 -> i1 {
%2 = moore.read %a : <i1>
moore.yield %2 : !moore.i1
Expand Down

0 comments on commit aae37b7

Please sign in to comment.