Skip to content

Commit

Permalink
- 1 todo
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander.nutz committed Jun 4, 2024
1 parent 102c27e commit 388fe2a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions ir/analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

#include "ir.h"


bool vx_IrOp_after(vx_IrOp *op, vx_IrOp *after) {
for (; op; op = op->next)
if (op == after)
return true;
return false;
}

bool vx_IrBlock_vardecl_is_in_ins(vx_IrBlock *block, vx_IrVar var) {
vx_IrBlock *root = vx_IrBlock_root(block);
for (size_t k = 0; k < root->ins_len; k ++) {
Expand Down
1 change: 1 addition & 0 deletions ir/ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ bool vx_IrOp_is_volatile(vx_IrOp *op);
size_t vx_IrOp_inline_cost(vx_IrOp *op);
void vx_IrOp_steal_states(vx_IrOp *dest, const vx_IrOp *src);
bool vx_IrOp_is_tail(vx_IrOp *op);
bool vx_IrOp_after(vx_IrOp *op, vx_IrOp *after);

struct IrStaticIncrement {
bool detected;
Expand Down
4 changes: 2 additions & 2 deletions ir/opt/ll_jumps.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "../opt.h"


// we go trough all ops between the jump and the label
// if all of them have no effect (labels, nops), we can remove the jump instruction
static void part1(vx_IrBlock *block) {
Expand All @@ -17,8 +18,7 @@ static void part1(vx_IrBlock *block) {
if (decl->parent != op->parent)
continue;

// TODO: SHOULD NOT WORK
if (decl < op) // can't optimize if label decl before this decl
if (vx_IrOp_after(decl, op)) // can't optimize if label decl before this decl
continue;

bool can_opt = true;
Expand Down

0 comments on commit 388fe2a

Please sign in to comment.