Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions lib/Dialect/LLHD/Transforms/Mem2Reg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,15 +770,11 @@ void Promoter::findPromotableSlots() {
// Ignore uses outside of the region.
if (user->getParentRegion() != &region)
return true;
// Projection operations are okay as long as they are in the same block
// as any of their users.
// Projection operations are okay.
if (isa<SigArrayGetOp, SigExtractOp, SigStructExtractOp>(user)) {
for (auto *projectionUser : user->getUsers()) {
if (projectionUser->getBlock() != user->getBlock())
return false;
for (auto *projectionUser : user->getUsers())
if (checkedUsers.insert(projectionUser).second)
userWorklist.push_back(projectionUser);
}
projections.insert({user->getResult(0), operand});
return true;
}
Expand Down
26 changes: 26 additions & 0 deletions test/Dialect/LLHD/Transforms/mem2reg.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -1093,3 +1093,29 @@ hw.module @DominanceTest2() {
}
hw.output
}

// CHECK-LABEL: @ProjectionAndDriveInDifferentBlocks
hw.module @ProjectionAndDriveInDifferentBlocks(in %u: !hw.struct<f: i42>, in %v: i42, in %q: i1) {
%0 = llhd.constant_time <0ns, 0d, 1e>
%a = llhd.sig %u : !hw.struct<f: i42>
// CHECK: llhd.process
llhd.process {
// CHECK-NOT: llhd.drv
llhd.drv %a, %u after %0 : !hw.inout<struct<f: i42>>
// CHECK-NOT: llhd.sig.struct_extract
%1 = llhd.sig.struct_extract %a["f"] : !hw.inout<struct<f: i42>>
// CHECK-NEXT: cf.br ^bb1
cf.br ^bb1
^bb1:
// CHECK-NEXT: ^bb1
// CHECK-NOT: llhd.drv
// CHECK-NEXT: [[EXT:%.+]] = hw.struct_extract %u["f"]
// CHECK-NEXT: [[MUX:%.+]] = comb.mux %q, %v, [[EXT]]
// CHECK-NEXT: [[INJ:%.+]] = hw.struct_inject %u["f"], [[MUX]]
llhd.drv %1, %v after %0 if %q : !hw.inout<i42>
// CHECK-NEXT: llhd.constant_time
// CHECK-NEXT: llhd.drv %a, [[INJ]]
// CHECK-NEXT: llhd.halt
llhd.halt
}
}