X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=ir.c;h=ad86914e5feb6144876c31be9062f663e00d998b;hb=44e416e7907d3cb478deecdaa8a17474198c5afd;hp=c3569199106fdf0d50c321305466fd68a6822fa2;hpb=b311cd61637df4a65d91c92c0d195de99b116b88;p=xonotic%2Fgmqcc.git diff --git a/ir.c b/ir.c index c356919..ad86914 100644 --- a/ir.c +++ b/ir.c @@ -1265,12 +1265,13 @@ bool ir_value_life_insert(ir_value *self, size_t idx, ir_life_entry_t e) bool ir_value_life_merge(ir_value *self, size_t s) { size_t i; + const size_t vs = vec_size(self->life); ir_life_entry_t *life = NULL; ir_life_entry_t *before = NULL; ir_life_entry_t new_entry; /* Find the first range >= s */ - for (i = 0; i < vec_size(self->life); ++i) + for (i = 0; i < vs; ++i) { before = life; life = &self->life[i]; @@ -1278,7 +1279,7 @@ bool ir_value_life_merge(ir_value *self, size_t s) break; } /* nothing found? append */ - if (i == vec_size(self->life)) { + if (i == vs) { ir_life_entry_t e; if (life && life->end+1 == s) { @@ -2256,18 +2257,22 @@ bool ir_function_allocate_locals(ir_function *self) irerror(call->context, "internal error: unlocked parameter %s not found", v->name); goto error; } - ++opts_optimizationcount[OPTIM_CALL_STORES]; v->callparam = true; if (param < 8) ir_value_code_setaddr(v, OFS_PARM0 + 3*param); else { + size_t nprotos = vec_size(self->owner->extparam_protos); ir_value *ep; param -= 8; - if (vec_size(self->owner->extparam_protos) <= param) - ep = ir_gen_extparam_proto(self->owner); - else + if (nprotos > param) ep = self->owner->extparam_protos[param]; + else + { + ep = ir_gen_extparam_proto(self->owner); + while (++nprotos <= param) + ep = ir_gen_extparam_proto(self->owner); + } ir_instr_op(v->writes[0], 0, ep, true); call->params[param+8] = ep; } @@ -2456,7 +2461,6 @@ static bool ir_block_life_propagate(ir_block *self, ir_block *prev, bool *change { ir_instr *instr; ir_value *value; - bool tempbool; size_t i, o, p, mem; /* bitmasks which operands are read from or written to */ size_t read, write; @@ -2516,23 +2520,23 @@ static bool ir_block_life_propagate(ir_block *self, ir_block *prev, bool *change * since this function is run multiple times. */ /* con_err( "Value only written %s\n", value->name); */ - tempbool = ir_value_life_merge(value, instr->eid); - *changed = *changed || tempbool; + if (ir_value_life_merge(value, instr->eid)) + *changed = true; } else { /* since 'living' won't contain it * anymore, merge the value, since * (A) doesn't. */ - tempbool = ir_value_life_merge(value, instr->eid); - *changed = *changed || tempbool; + if (ir_value_life_merge(value, instr->eid)) + *changed = true; /* Then remove */ vec_remove(self->living, idx, 1); } /* Removing a vector removes all members */ for (mem = 0; mem < 3; ++mem) { if (value->members[mem] && vec_ir_value_find(self->living, value->members[mem], &idx)) { - tempbool = ir_value_life_merge(value->members[mem], instr->eid); - *changed = *changed || tempbool; + if (ir_value_life_merge(value->members[mem], instr->eid)) + *changed = true; vec_remove(self->living, idx, 1); } } @@ -2544,8 +2548,8 @@ static bool ir_block_life_propagate(ir_block *self, ir_block *prev, bool *change break; } if (mem == 3 && vec_ir_value_find(self->living, value, &idx)) { - tempbool = ir_value_life_merge(value, instr->eid); - *changed = *changed || tempbool; + if (ir_value_life_merge(value, instr->eid)) + *changed = true; vec_remove(self->living, idx, 1); } } @@ -2636,13 +2640,12 @@ static bool ir_block_life_propagate(ir_block *self, ir_block *prev, bool *change } /* (A) */ - tempbool = ir_block_living_add_instr(self, instr->eid); - /*con_err( "living added values\n");*/ - *changed = *changed || tempbool; + if (ir_block_living_add_instr(self, instr->eid)) + *changed = true; } /* the "entry" instruction ID */ - tempbool = ir_block_living_add_instr(self, self->entry_id); - *changed = *changed || tempbool; + if (ir_block_living_add_instr(self, self->entry_id)) + *changed = true; if (self->run_id == self->owner->run_id) return true; @@ -3114,7 +3117,7 @@ static ir_value* ir_gen_extparam_proto(ir_builder *ir) ir_value *global; char name[128]; - snprintf(name, sizeof(name), "EXTPARM#%i", (int)(vec_size(ir->extparam_protos)+8)); + snprintf(name, sizeof(name), "EXTPARM#%i", (int)(vec_size(ir->extparam_protos))); global = ir_value_var(name, store_global, TYPE_VECTOR); vec_push(ir->extparam_protos, global); @@ -3201,7 +3204,7 @@ static bool gen_function_varargs_copy(ir_function *self) code_push_statement(&stmt, self->context.line); continue; } - ext = i - 8; + ext = i - 9; if (ext >= vec_size(ir->extparams)) ir_gen_extparam(ir);