forked from eden-emu/eden
		
	shader: Remove invalidated blocks in dead code elimination pass
This commit is contained in:
		
							parent
							
								
									12d7acf707
								
							
						
					
					
						commit
						3c80ebf1e2
					
				
					 1 changed files with 6 additions and 3 deletions
				
			
		|  | @ -14,9 +14,12 @@ void DeadCodeEliminationPass(IR::Program& program) { | ||||||
|     // We iterate over the instructions in reverse order.
 |     // We iterate over the instructions in reverse order.
 | ||||||
|     // This is because removing an instruction reduces the number of uses for earlier instructions.
 |     // This is because removing an instruction reduces the number of uses for earlier instructions.
 | ||||||
|     for (IR::Block* const block : program.post_order_blocks) { |     for (IR::Block* const block : program.post_order_blocks) { | ||||||
|         for (IR::Inst& inst : block->Instructions() | std::views::reverse) { |         auto it{block->end()}; | ||||||
|             if (!inst.HasUses() && !inst.MayHaveSideEffects()) { |         while (it != block->begin()) { | ||||||
|                 inst.Invalidate(); |             --it; | ||||||
|  |             if (!it->HasUses() && !it->MayHaveSideEffects()) { | ||||||
|  |                 it->Invalidate(); | ||||||
|  |                 it = block->Instructions().erase(it); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 ReinUsesLisp
						ReinUsesLisp