File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -307,14 +307,15 @@ void FirMemLowering::lowerMemoriesInModule(
307
307
LLVM_DEBUG (llvm::dbgs () << " Lowering " << mems.size () << " memories in "
308
308
<< module .getName () << " \n " );
309
309
310
- hw::ConstantOp constOneOp ;
310
+ DenseMap< unsigned , Value> constOneOps ;
311
311
auto constOne = [&](unsigned width = 1 ) {
312
- if (!constOneOp) {
312
+ auto it = constOneOps.try_emplace (width, Value{});
313
+ if (it.second ) {
313
314
auto builder = OpBuilder::atBlockBegin (module .getBodyBlock ());
314
- constOneOp = builder.create <hw::ConstantOp>(
315
+ it. first -> second = builder.create <hw::ConstantOp>(
315
316
module .getLoc (), builder.getIntegerType (width), 1 );
316
317
}
317
- return constOneOp ;
318
+ return it. first -> second ;
318
319
};
319
320
auto valueOrOne = [&](Value value, unsigned width = 1 ) {
320
321
return value ? value : constOne (width);
You can’t perform that action at this time.
0 commit comments