From 86a48bfea137500c525fabd6ee5bfdfadef3144b Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Sat, 14 Jan 2023 13:23:03 +0000 Subject: [PATCH] a little more cleanup --- compiler_and_linker/unsorted/Alias.c | 17 ++++------------- .../unsorted/InterferenceGraph.c | 15 +++++---------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/compiler_and_linker/unsorted/Alias.c b/compiler_and_linker/unsorted/Alias.c index b86fb41..8223bf4 100644 --- a/compiler_and_linker/unsorted/Alias.c +++ b/compiler_and_linker/unsorted/Alias.c @@ -309,30 +309,24 @@ static int addresspropagatestouse(int candidateID, int useID) { if (candidate_pcode->block == use_pcode->block && precedes(candidate_pcode, use_pcode)) { for (scan = candidate_pcode->nextPCode; scan && scan != use_pcode; scan = scan->nextPCode) { - op = scan->args; - i = scan->argCount; - while (i--) { + for (op = scan->args, i = scan->argCount; i--; op++) { if (op->kind == PCOp_REGISTER && op->arg == RegClass_GPR && (op->data.reg.effect & EffectWrite) && op->data.reg.reg == reg) return 1; - op++; } } } else { if (!bitvectorgetbit(candidateID, propinfo[use_pcode->block->blockIndex].vec8)) { if (bitvectorgetbit(candidate_pcode->defID, usedefinfo[use_pcode->block->blockIndex].defvec8)) { for (scan = use_pcode->block->firstPCode; scan && scan != use_pcode; scan = scan->nextPCode) { - op = scan->args; - i = scan->argCount; - while (i--) { + for (op = scan->args, i = scan->argCount; i--; op++) { if (op->kind == PCOp_REGISTER && op->arg == RegClass_GPR && (op->data.reg.effect & EffectWrite) && op->data.reg.reg == reg) return 1; - op++; } } } else { @@ -343,15 +337,12 @@ static int addresspropagatestouse(int candidateID, int useID) { for (scan = use_pcode->block->firstPCode; scan; scan = scan->nextPCode) { if (scan == use_pcode) break; - op = scan->args; - i = scan->argCount; - while (i--) { + for (op = scan->args, i = scan->argCount; i--; op++) { if (op->kind == PCOp_REGISTER && op->arg == RegClass_GPR && (op->data.reg.effect & EffectWrite) && op->data.reg.reg == reg) return 1; - op++; } } } @@ -538,7 +529,7 @@ void gather_alias_info(void) { if ( (!(pcode->flags & (fIsWrite | fPCodeFlag40000)) || op != pcode->args) && op->kind == PCOp_REGISTER && - (RegClass) op->arg == RegClass_GPR && + op->arg == RegClass_GPR && (op->data.reg.effect & EffectRead) ) { alias_array[aliases_idx] = NULL; diff --git a/compiler_and_linker/unsorted/InterferenceGraph.c b/compiler_and_linker/unsorted/InterferenceGraph.c index 99f4512..d589502 100644 --- a/compiler_and_linker/unsorted/InterferenceGraph.c +++ b/compiler_and_linker/unsorted/InterferenceGraph.c @@ -33,16 +33,14 @@ int interferes(UInt32 a, UInt32 b) { } static void buildinterferencematrix(void) { - UInt32 regs; // r31 PCodeBlock *block; // r30 PCode *instr; // r29 - UInt32 *vec; // r28 PCodeArg *op; - int reg; + UInt32 *vec; // r28 UInt32 i; UInt32 j; - regs = used_virtual_registers[coloring_class]; + UInt32 regs = used_virtual_registers[coloring_class]; interferencematrix = oalloc(4 * ((((regs * regs) / 2) + 31) >> 5)); bitvectorinitialize(interferencematrix, (regs * regs) / 2, 0); @@ -57,7 +55,7 @@ static void buildinterferencematrix(void) { for (instr = block->lastPCode; instr; instr = instr->prevPCode) { for (op = instr->args, i = instr->argCount; i--; op++) { if (PC_OP_IS_WRITE_ANY_REGISTER(op, coloring_class)) { - reg = op->data.reg.reg; + int reg = op->data.reg.reg; bitvectorclearbit(reg, vec); for (j = 0; j < regs; j++) { if (bitvectorgetbit(j, vec)) { @@ -75,7 +73,7 @@ static void buildinterferencematrix(void) { for (op = instr->args, i = instr->argCount; i--; op++) { if (PC_OP_IS_READ_ANY_REGISTER(op, coloring_class)) { - reg = op->data.reg.reg; + int reg = op->data.reg.reg; if (bitvectorgetbit(op->data.reg.reg, vec) == 0) op->data.reg.effect |= Effect4; bitvectorsetbit(reg, vec); @@ -124,14 +122,11 @@ static void buildinterferencematrix(void) { CError_ASSERT(226, i <= instr->argCount); } - op = instr->args + i; - while (i < instr->argCount) { + for (op = instr->args + i; i < instr->argCount; i++, op++) { if (op->kind == PCOp_REGISTER && op->arg == RegClass_GPR) { for (j = 0; j < n_scratch_registers[coloring_class]; j++) makeinterfere(op->data.reg.reg, scratch_registers[coloring_class][j]); } - i++; - op++; } } }