From 4a66e9729175a89833e5db784bb64e6a7f60cdf2 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 27 Jan 2023 16:41:31 -0800 Subject: Register allocation during phi elimination. (#2613) * Register allocation during phi elimination. * Enhance the test case. * Cleanup line breaks in test case. * remove unncessary line break changes. * More cleanups. --------- Co-authored-by: Yong He --- source/slang/slang-emit.cpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'source/slang/slang-emit.cpp') diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 00fa5d3cb..3d923179c 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -811,10 +811,17 @@ Result linkAndOptimizeIR( lowerBitCast(targetRequest, irModule); simplifyIR(irModule); + eliminateMultiLevelBreak(irModule); + + // As a late step, we need to take the SSA-form IR and move things *out* + // of SSA form, by eliminating all "phi nodes" (block parameters) and + // introducing explicit temporaries instead. Doing this at the IR level + // means that subsequent emit logic doesn't need to contend with the + // complexities of blocks with parameters. + // { // Get the liveness mode. const LivenessMode livenessMode = codeGenContext->shouldTrackLiveness() ? LivenessMode::Enabled : LivenessMode::Disabled; - // // Downstream targets may benefit from having live-range information for // local variables, and our IR currently encodes a reasonably good version @@ -830,22 +837,11 @@ Result linkAndOptimizeIR( LivenessUtil::addVariableRangeStarts(irModule, livenessMode); } - eliminateMultiLevelBreak(irModule); - - // As a late step, we need to take the SSA-form IR and move things *out* - // of SSA form, by eliminating all "phi nodes" (block parameters) and - // introducing explicit temporaries instead. Doing this at the IR level - // means that subsequent emit logic doesn't need to contend with the - // complexities of blocks with parameters. - // - - { - // We only want to accumulate locations if liveness tracking is enabled. - eliminatePhis(livenessMode, irModule); + // We only want to accumulate locations if liveness tracking is enabled. + eliminatePhis(livenessMode, irModule); #if 0 - dumpIRIfEnabled(codeGenContext, irModule, "PHIS ELIMINATED"); + dumpIRIfEnabled(codeGenContext, irModule, "PHIS ELIMINATED"); #endif - } // If liveness is enabled add liveness ranges based on the accumulated liveness locations -- cgit v1.2.3