Skip to content

Commit f7dd0f9

Browse files
authored
format code (#97)
Co-authored-by: slangbot <[email protected]>
1 parent bbb42ed commit f7dd0f9

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

source/slang/slang-ir-transform-params-to-constref.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ struct TransformParamsToConstRefContext
204204
break;
205205
}
206206
}
207-
207+
208208
if (!isRelatedToUpdatedParam)
209209
continue;
210210

@@ -274,7 +274,7 @@ struct TransformParamsToConstRefContext
274274
void eliminateLoadStorePairsForEntryPoint(IRFunc* func)
275275
{
276276
List<IRInst*> toRemove;
277-
277+
278278
// Look for patterns: load(ptr) followed by store(var, load_result)
279279
// This can be optimized to direct pointer usage
280280
for (auto block : func->getBlocks())
@@ -285,17 +285,17 @@ struct TransformParamsToConstRefContext
285285
{
286286
auto storedValue = storeInst->getVal();
287287
auto destPtr = storeInst->getPtr();
288-
288+
289289
// Check if we're storing a load result
290290
if (auto loadInst = as<IRLoad>(storedValue))
291291
{
292292
auto loadedPtr = loadInst->getPtr();
293-
293+
294294
// IMPORTANT: Only optimize if destPtr is a variable (kIROp_Var)
295295
// Don't optimize stores to buffer elements or other meaningful destinations
296296
if (!as<IRVar>(destPtr))
297297
continue;
298-
298+
299299
// Check if this load has only one use (this store)
300300
bool loadHasOnlyOneUse = true;
301301
UInt useCount = 0;
@@ -308,16 +308,16 @@ struct TransformParamsToConstRefContext
308308
break;
309309
}
310310
}
311-
311+
312312
if (loadHasOnlyOneUse)
313313
{
314314
// Replace all uses of destPtr with loadedPtr
315315
destPtr->replaceUsesWith(loadedPtr);
316-
316+
317317
// Mark both instructions for removal
318318
toRemove.add(storeInst);
319319
toRemove.add(loadInst);
320-
320+
321321
// Also remove the variable if it's only used by this store
322322
if (auto varInst = as<IRVar>(destPtr))
323323
{
@@ -335,14 +335,14 @@ struct TransformParamsToConstRefContext
335335
toRemove.add(varInst);
336336
}
337337
}
338-
338+
339339
changed = true;
340340
}
341341
}
342342
}
343343
}
344344
}
345-
345+
346346
// Remove marked instructions
347347
for (auto inst : toRemove)
348348
{
@@ -450,17 +450,19 @@ struct TransformParamsToConstRefContext
450450
}
451451

452452
// Handle entry point functions separately - they don't get processed by processFunc
453-
// but they still need load/store optimization for parameters that come from global parameters
453+
// but they still need load/store optimization for parameters that come from global
454+
// parameters
454455
for (auto inst = module->getModuleInst()->getFirstChild(); inst; inst = inst->getNextInst())
455456
{
456457
auto func = as<IRFunc>(inst);
457458
if (!func || !func->isDefinition())
458459
continue;
459-
460+
460461
// Only process entry point functions that weren't already processed
461462
if (!shouldProcessFunction(func))
462463
{
463-
// For entry point functions, use a broader optimization since we don't have specific updatedParams
464+
// For entry point functions, use a broader optimization since we don't have
465+
// specific updatedParams
464466
eliminateLoadStorePairsForEntryPoint(func);
465467
}
466468
}

0 commit comments

Comments
 (0)