Reorder instructions to use simpler and more efficient checks

This commit is contained in:
Dmitry Stogov 2023-03-15 23:49:50 +03:00
parent 2b4586fa0b
commit 09409898ea
2 changed files with 11 additions and 45 deletions

42
ir.c
View File

@ -1423,16 +1423,7 @@ static ir_ref ir_find_aliasing_load(ir_ctx *ctx, ir_ref ref, ir_type type, ir_re
}
} else if (insn->op == IR_RSTORE) {
modified_regset |= (1 << insn->op3);
} else if (insn->op == IR_START
|| insn->op == IR_BEGIN
|| insn->op == IR_IF_TRUE
|| insn->op == IR_IF_FALSE
|| insn->op == IR_CASE_VAL
|| insn->op == IR_CASE_DEFAULT
|| insn->op == IR_MERGE
|| insn->op == IR_LOOP_BEGIN
|| insn->op == IR_ENTRY
|| insn->op == IR_CALL) {
} else if (insn->op >= IR_START || insn->op == IR_CALL) {
return IR_UNUSED;
}
ref = insn->op1;
@ -1929,15 +1920,7 @@ void _ir_GUARD(ir_ctx *ctx, ir_ref condition, ir_ref addr)
condition = IR_FALSE;
break;
}
} else if (insn->op == IR_START
|| insn->op == IR_BEGIN
|| insn->op == IR_IF_TRUE
|| insn->op == IR_IF_FALSE
|| insn->op == IR_CASE_VAL
|| insn->op == IR_CASE_DEFAULT
|| insn->op == IR_MERGE
|| insn->op == IR_LOOP_BEGIN
|| insn->op == IR_ENTRY) {
} else if (insn->op >= IR_START) {
break;
}
ref = insn->op1;
@ -1969,15 +1952,7 @@ void _ir_GUARD_NOT(ir_ctx *ctx, ir_ref condition, ir_ref addr)
condition = IR_TRUE;
break;
}
} else if (insn->op == IR_START
|| insn->op == IR_BEGIN
|| insn->op == IR_IF_TRUE
|| insn->op == IR_IF_FALSE
|| insn->op == IR_CASE_VAL
|| insn->op == IR_CASE_DEFAULT
|| insn->op == IR_MERGE
|| insn->op == IR_LOOP_BEGIN
|| insn->op == IR_ENTRY) {
} else if (insn->op >= IR_START) {
break;
}
ref = insn->op1;
@ -2115,16 +2090,7 @@ check_aliasing:
if (ir_check_partial_aliasing(ctx, addr, insn->op2, type, type2) != IR_NO_ALIAS) {
break;
}
} else if (insn->op == IR_START
|| insn->op == IR_BEGIN
|| insn->op == IR_IF_TRUE
|| insn->op == IR_IF_FALSE
|| insn->op == IR_CASE_VAL
|| insn->op == IR_CASE_DEFAULT
|| insn->op == IR_MERGE
|| insn->op == IR_LOOP_BEGIN
|| insn->op == IR_ENTRY
|| insn->op == IR_CALL) {
} else if (insn->op >= IR_START || insn->op == IR_CALL) {
break;
}
prev = ref;

14
ir.h
View File

@ -287,6 +287,13 @@ typedef enum _ir_type {
_(TRAP, x1, src, ___, ___) /* DebugBreak */ \
/* memory reference ops (A, H, U, S, TMP, STR, NEW, X, V) ??? */ \
\
/* guards */ \
_(GUARD, c3, src, def, def) /* IF without second successor */ \
_(GUARD_NOT , c3, src, def, def) /* IF without second successor */ \
\
/* deoptimization */ \
_(SNAPSHOT, xN, src, def, def) /* SNAPSHOT(src, args...) */ \
\
/* control-flow nodes */ \
_(START, S0X2, ret, ent, ___) /* function start */ \
_(ENTRY, S0X2, num, ent, ___) /* code entry (op3 keeps addr) */ \
@ -305,13 +312,6 @@ typedef enum _ir_type {
_(IJMP, T2X1, src, def, ret) /* computed goto */ \
_(UNREACHABLE, T2X1, src, def, ret) /* unreachable (tailcall, etc) */ \
\
/* guards */ \
_(GUARD, c3, src, def, def) /* IF without second successor */ \
_(GUARD_NOT , c3, src, def, def) /* IF without second successor */ \
\
/* deoptimization */ \
_(SNAPSHOT, xN, src, def, def) /* SNAPSHOT(src, args...) */ \
\
/* deoptimization helper */ \
_(EXITCALL, x2, src, def, ___) /* save CPU regs and call op2 */ \