Skip to content

Commit

Permalink
cg bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander.nutz committed Sep 20, 2024
1 parent 2ec941a commit d7292ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion cg/x86_stupid/cg.c
Original file line number Diff line number Diff line change
Expand Up @@ -985,8 +985,12 @@ static vx_IrOp* emiti(vx_IrBlock* block, vx_IrOp *prev, vx_IrOp* op, FILE* file)
default: break;
}

size_t multiplicationNumNotImm = 0;
if (idx_loc && idx_loc->type != LOC_IMM) multiplicationNumNotImm ++;
if (elsize_loc && elsize_loc->type != LOC_IMM) multiplicationNumNotImm ++;

// branch always taken if loadea or storeea
if (numMemOrEa < 2)
if (numMemOrEa < 2 && multiplicationNumNotImm < 2)
{
Location* base_prim_loc = base_loc ? start_as_primitive(base_loc, file) : NULL;
Location* idx_prim_loc = idx_loc ? start_as_primitive(idx_loc, file) : NULL;
Expand Down
7 changes: 5 additions & 2 deletions ir/transform/normalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

void vx_CIrBlock_normalize(vx_IrBlock *block)
{
assert(block->is_root);

for (vx_IrOp *op = block->first; op; op = op->next) {
if (op->id == VX_IR_OP_CFOR) {
vx_IrBlock *new = vx_IrBlock_initHeap(block, op);
Expand Down Expand Up @@ -47,5 +45,10 @@ void vx_CIrBlock_normalize(vx_IrBlock *block)
op->id = VX_IR_OP_FLATTEN_PLEASE;
vx_IrOp_addParam_s(op, VX_IR_NAME_BLOCK, VX_IR_VALUE_BLK(new));
}

FOR_INPUTS(op, inp, {
if (inp.type == VX_IR_VAL_BLOCK)
vx_CIrBlock_normalize(inp.block);
});
}
}

0 comments on commit d7292ec

Please sign in to comment.