| ... | @@ -8090,6 +8090,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -8090,6 +8090,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 8090 | if (!target_val) | 8090 | if (!target_val) |
| 8091 | return ir_unreach_error(ira); | 8091 | return ir_unreach_error(ira); |
| 8092 | | 8092 | |
| | 8093 | IrBasicBlock *old_dest_block = switch_br_instruction->else_block; |
| 8093 | for (size_t i = 0; i < case_count; i += 1) { | 8094 | for (size_t i = 0; i < case_count; i += 1) { |
| 8094 | IrInstructionSwitchBrCase *old_case = &switch_br_instruction->cases[i]; | 8095 | IrInstructionSwitchBrCase *old_case = &switch_br_instruction->cases[i]; |
| 8095 | IrInstruction *case_value = old_case->value->other; | 8096 | IrInstruction *case_value = old_case->value->other; |
| ... | @@ -8111,17 +8112,18 @@ static TypeTableEntry *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -8111,17 +8112,18 @@ static TypeTableEntry *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 8111 | return ir_unreach_error(ira); | 8112 | return ir_unreach_error(ira); |
| 8112 | | 8113 | |
| 8113 | if (const_values_equal(target_val, case_val, target_value->type_entry)) { | 8114 | if (const_values_equal(target_val, case_val, target_value->type_entry)) { |
| 8114 | IrBasicBlock *old_dest_block = old_case->block; | 8115 | old_dest_block = old_case->block; |
| 8115 | if (is_comptime || old_dest_block->ref_count == 1) { | 8116 | break; |
| 8116 | return ir_inline_bb(ira, &switch_br_instruction->base, old_dest_block); | | |
| 8117 | } else { | | |
| 8118 | IrBasicBlock *new_dest_block = ir_get_new_bb(ira, old_dest_block); | | |
| 8119 | ir_build_br_from(&ira->new_irb, &switch_br_instruction->base, new_dest_block); | | |
| 8120 | return ir_finish_anal(ira, ira->codegen->builtin_types.entry_unreachable); | | |
| 8121 | } | | |
| 8122 | } | 8117 | } |
| 8123 | } | 8118 | } |
| 8124 | | 8119 | |
| | 8120 | if (is_comptime || old_dest_block->ref_count == 1) { |
| | 8121 | return ir_inline_bb(ira, &switch_br_instruction->base, old_dest_block); |
| | 8122 | } else { |
| | 8123 | IrBasicBlock *new_dest_block = ir_get_new_bb(ira, old_dest_block); |
| | 8124 | ir_build_br_from(&ira->new_irb, &switch_br_instruction->base, new_dest_block); |
| | 8125 | return ir_finish_anal(ira, ira->codegen->builtin_types.entry_unreachable); |
| | 8126 | } |
| 8125 | } | 8127 | } |
| 8126 | | 8128 | |
| 8127 | IrInstructionSwitchBrCase *cases = allocate<IrInstructionSwitchBrCase>(case_count); | 8129 | IrInstructionSwitchBrCase *cases = allocate<IrInstructionSwitchBrCase>(case_count); |