Skip to content

Commit

Permalink
Reduce number of useless spill loads
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Sep 12, 2023
1 parent 7650500 commit d032f87
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ir_ra.c
Original file line number Diff line number Diff line change
Expand Up @@ -3653,7 +3653,7 @@ static void assign_regs(ir_ctx *ctx)
ir_ref i;
ir_live_interval *ival, *top_ival;
ir_use_pos *use_pos;
int8_t reg;
int8_t reg, old_reg;
ir_ref ref;
ir_regset used_regs = 0;

Expand Down Expand Up @@ -3778,14 +3778,18 @@ static void assign_regs(ir_ctx *ctx)
/* Spilled PHI var is passed through memory */
reg = IR_REG_NONE;
}
} else if (use_pos->hint_ref < 0) {
} else if (use_pos->hint_ref < 0
&& ctx->use_lists[-use_pos->hint_ref].count > 1
&& (old_reg = ir_get_alocated_reg(ctx, -use_pos->hint_ref, use_pos->op_num)) != IR_REG_NONE
&& (old_reg & (IR_REG_SPILL_SPECIAL|IR_REG_SPILL_LOAD))) {
/* Force spill load */
// TODO: Find a better solution ???
if (top_ival->flags & IR_LIVE_INTERVAL_SPILL_SPECIAL) {
reg |= IR_REG_SPILL_SPECIAL;
} else {
reg |= IR_REG_SPILL_LOAD;
}
IR_ASSERT(reg == old_reg);
} else {
/* reuse register without spill load */
}
Expand Down

0 comments on commit d032f87

Please sign in to comment.