diff --git a/ir_ra.c b/ir_ra.c index 308bbcf..847d0d8 100644 --- a/ir_ra.c +++ b/ir_ra.c @@ -1506,7 +1506,15 @@ static ir_reg ir_allocate_blocked_reg(ir_ctx *ctx, int current, uint32_t len, ir /* all other intervals are used before current, so it is best to spill current itself */ /* assign spill slot to current */ /* split current before its first use position that requires a register */ - ir_live_pos split_pos = ir_find_optimal_split_position(ctx, current, ival, ival->range.start, next_use_pos - 1); + ir_live_pos split_pos; + + if (next_use_pos == ival->range.start) { + IR_ASSERT(use_pos && use_pos->op_num == 0); + /* split right after definition */ + split_pos = next_use_pos + 1; + } else { + split_pos = ir_find_optimal_split_position(ctx, current, ival, ival->range.start, next_use_pos - 1); + } if (split_pos > ival->range.start) { IR_LOG_LSRA(" ---- Conflict with others", current, ival, " (all others are used before)"); diff --git a/ir_x86.dasc b/ir_x86.dasc index 9f6dd42..349e954 100644 --- a/ir_x86.dasc +++ b/ir_x86.dasc @@ -959,6 +959,8 @@ uint8_t ir_get_use_flags(ir_ctx *ctx, ir_ref ref, int op_num) case IR_DIV_INT: case IR_MOD_INT: return (op_num == 2) ? IR_USE_SHOULD_BE_IN_REG : IR_USE_MUST_BE_IN_REG; + case IR_PARAM: + return IR_USE_SHOULD_BE_IN_REG; } return IR_USE_MUST_BE_IN_REG;