Skip to content

Commit 74683f6

Browse files
committed
[NFC][SeqToSV] Fix constant caching in FIR mem loweringi
1 parent 02f0bff commit 74683f6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/Conversion/SeqToSV/FirMemLowering.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,14 +307,15 @@ void FirMemLowering::lowerMemoriesInModule(
307307
LLVM_DEBUG(llvm::dbgs() << "Lowering " << mems.size() << " memories in "
308308
<< module.getName() << "\n");
309309

310-
hw::ConstantOp constOneOp;
310+
DenseMap<unsigned, Value> constOneOps;
311311
auto constOne = [&](unsigned width = 1) {
312-
if (!constOneOp) {
312+
auto it = constOneOps.try_emplace(width, Value{});
313+
if (it.second) {
313314
auto builder = OpBuilder::atBlockBegin(module.getBodyBlock());
314-
constOneOp = builder.create<hw::ConstantOp>(
315+
it.first->second = builder.create<hw::ConstantOp>(
315316
module.getLoc(), builder.getIntegerType(width), 1);
316317
}
317-
return constOneOp;
318+
return it.first->second;
318319
};
319320
auto valueOrOne = [&](Value value, unsigned width = 1) {
320321
return value ? value : constOne(width);

0 commit comments

Comments
 (0)