Skip to content

Commit

Permalink
Remove useless opt calls
Browse files Browse the repository at this point in the history
  • Loading branch information
DevelLightStudio committed May 28, 2024
1 parent 4fa88b3 commit 9519d94
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 6 deletions.
3 changes: 0 additions & 3 deletions ir/opt/loop_simplify.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ void vx_opt_loop_simplify(vx_IrView view,
vx_IrOp *op = (vx_IrOp *) vx_IrView_take(view);

vx_IrBlock *cond = vx_IrOp_param(op, VX_IR_NAME_COND)->block;
opt(cond); // !
const vx_IrVar condVar = cond->outs[0];

// if it will always we 0, we optimize it out
Expand All @@ -17,8 +16,6 @@ void vx_opt_loop_simplify(vx_IrView view,
goto next;
}

opt(vx_IrOp_param(op, VX_IR_NAME_LOOP_DO)->block);

// if it will never be 0 (not might be 0), it is always true => infinite loop
if (!vx_Irblock_mightbe_var(cond, condVar, (vx_IrValue) { .type = VX_IR_VAL_IMM_INT, .imm_int = 0 })) {
vx_IrOp new;
Expand Down
3 changes: 0 additions & 3 deletions ir/opt/reduce_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ void vx_opt_reduce_if(vx_IrView view,
vx_IrOp *op = (vx_IrOp *) vx_IrView_take(view);

vx_IrBlock *cond = vx_IrOp_param(op, VX_IR_NAME_COND)->block;
opt(cond); // !
const vx_IrVar condVar = cond->outs[0];

vx_IrValue *pthen = vx_IrOp_param(op, VX_IR_NAME_COND_THEN);
if (pthen) {
vx_IrBlock *then = pthen->block;
opt(then);

// if it will never be 0 (not might be 0), it is always true => only execute then block
if (!vx_Irblock_mightbe_var(cond, condVar, (vx_IrValue) { .type = VX_IR_VAL_IMM_INT, .imm_int = 0 })) {
Expand All @@ -33,7 +31,6 @@ void vx_opt_reduce_if(vx_IrView view,
vx_IrValue *pelse = vx_IrOp_param(op, VX_IR_NAME_COND_ELSE);
if (pelse) {
vx_IrBlock *els = pelse->block;
opt(els);

// if it will always we 0, only the else block will ever be executed
if (vx_Irblock_alwaysis_var(cond, condVar, (vx_IrValue) { .type = VX_IR_VAL_IMM_INT, .imm_int = 0 })) {
Expand Down

0 comments on commit 9519d94

Please sign in to comment.