Skip to content

Commit

Permalink
Merge pull request #2299 from KhronosGroup/fix-2285
Browse files Browse the repository at this point in the history
Block loop optimization if Phi is used.
  • Loading branch information
HansKristian-Work authored Mar 18, 2024
2 parents 1e3f31e + b4c84bb commit 7d92d7d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions spirv_glsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16747,8 +16747,11 @@ bool CompilerGLSL::attempt_emit_loop_header(SPIRBlock &block, SPIRBlock::Method

bool condition_is_temporary = forced_temporaries.find(block.condition) == end(forced_temporaries);

bool flushes_phi = flush_phi_required(block.self, block.true_block) ||
flush_phi_required(block.self, block.false_block);

// This can work! We only did trivial things which could be forwarded in block body!
if (current_count == statement_count && condition_is_temporary)
if (!flushes_phi && current_count == statement_count && condition_is_temporary)
{
switch (continue_type)
{
Expand Down Expand Up @@ -16827,7 +16830,10 @@ bool CompilerGLSL::attempt_emit_loop_header(SPIRBlock &block, SPIRBlock::Method

bool condition_is_temporary = forced_temporaries.find(child.condition) == end(forced_temporaries);

if (current_count == statement_count && condition_is_temporary)
bool flushes_phi = flush_phi_required(child.self, child.true_block) ||
flush_phi_required(child.self, child.false_block);

if (!flushes_phi && current_count == statement_count && condition_is_temporary)
{
uint32_t target_block = child.true_block;

Expand Down

0 comments on commit 7d92d7d

Please sign in to comment.