mirror of
				https://git.suyu.dev/suyu/suyu
				synced 2025-11-03 16:39:01 -06:00 
			
		
		
		
	shader: Remove invalidated blocks in dead code elimination pass
This commit is contained in:
		@@ -14,9 +14,12 @@ void DeadCodeEliminationPass(IR::Program& program) {
 | 
			
		||||
    // We iterate over the instructions in reverse order.
 | 
			
		||||
    // 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::Inst& inst : block->Instructions() | std::views::reverse) {
 | 
			
		||||
            if (!inst.HasUses() && !inst.MayHaveSideEffects()) {
 | 
			
		||||
                inst.Invalidate();
 | 
			
		||||
        auto it{block->end()};
 | 
			
		||||
        while (it != block->begin()) {
 | 
			
		||||
            --it;
 | 
			
		||||
            if (!it->HasUses() && !it->MayHaveSideEffects()) {
 | 
			
		||||
                it->Invalidate();
 | 
			
		||||
                it = block->Instructions().erase(it);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user