Skip to content

Commit b932c26

Browse files
committed
Update IR
IR commit: 3d0124a06ee4321e1305f893b74840033d939e88
1 parent 2c45d67 commit b932c26

File tree

3 files changed

+68
-3
lines changed

3 files changed

+68
-3
lines changed

ext/opcache/jit/ir/ir.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2413,10 +2413,18 @@ static ir_ref _ir_fold_condition(ir_ctx *ctx, ir_ref ref)
24132413
if (IR_IS_TYPE_INT(op2_insn->type) && op2_insn->val.u64 == 0) {
24142414
ref = insn->op1;
24152415
insn = &ctx->ir_base[ref];
2416+
if (insn->op == IR_ALLOCA || insn->op == IR_VADDR) {
2417+
return IR_TRUE;
2418+
}
24162419
}
24172420
} else if (insn->op == IR_EQ && insn->op2 == IR_TRUE) {
24182421
ref = insn->op1;
24192422
insn = &ctx->ir_base[ref];
2423+
} else if (insn->op == IR_EQ && insn->op2 == IR_NULL) {
2424+
ir_insn *op1_insn = &ctx->ir_base[insn->op1];
2425+
if (op1_insn->op == IR_ALLOCA || op1_insn->op == IR_VADDR) {
2426+
return IR_FALSE;
2427+
}
24202428
}
24212429
// while (insn->op == IR_SEXT || insn->op == IR_ZEXT || insn->op == IR_BITCAST) {
24222430
// ref = insn->op1;

ext/opcache/jit/ir/ir_fold.h

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,9 @@ IR_FOLD(EQ(SEXT, C_I32))
14641464
IR_FOLD(EQ(SEXT, C_I64))
14651465
IR_FOLD(EQ(SEXT, C_ADDR))
14661466
{
1467-
if (op2_insn->val.u64 == 0 && ctx->ir_base[op1_insn->op1].type == IR_BOOL) {
1467+
if (ctx->use_lists && ctx->use_lists[op1_insn->op1].count != 1) {
1468+
/* pass */
1469+
} else if (op2_insn->val.u64 == 0 && ctx->ir_base[op1_insn->op1].type == IR_BOOL) {
14681470
opt = IR_OPT(IR_NOT, IR_BOOL);
14691471
op1 = op1_insn->op1;
14701472
op2 = IR_UNUSED;
@@ -1509,7 +1511,9 @@ IR_FOLD(NE(SEXT, C_I32))
15091511
IR_FOLD(NE(SEXT, C_I64))
15101512
IR_FOLD(NE(SEXT, C_ADDR))
15111513
{
1512-
if (op2_insn->val.u64 == 0 && ctx->ir_base[op1_insn->op1].type == IR_BOOL) {
1514+
if (ctx->use_lists && ctx->use_lists[op1_insn->op1].count != 1) {
1515+
/* pass */
1516+
} else if (op2_insn->val.u64 == 0 && ctx->ir_base[op1_insn->op1].type == IR_BOOL) {
15131517
IR_FOLD_COPY(op1_insn->op1);
15141518
} else {
15151519
ir_type type = ctx->ir_base[op1_insn->op1].type;
@@ -2464,6 +2468,17 @@ IR_FOLD(SEXT(AND))
24642468
IR_FOLD_NEXT;
24652469
}
24662470

2471+
IR_FOLD(SEXT(SHR))
2472+
{
2473+
if (IR_IS_CONST_REF(op1_insn->op2)
2474+
&& !IR_IS_SYM_CONST(ctx->ir_base[op1_insn->op2].op)
2475+
&& ctx->ir_base[op1_insn->op2].val.u64 != 0) {
2476+
opt = IR_OPT(IR_ZEXT, IR_OPT_TYPE(opt));
2477+
IR_FOLD_RESTART;
2478+
}
2479+
IR_FOLD_NEXT;
2480+
}
2481+
24672482
IR_FOLD(TRUNC(AND))
24682483
{
24692484
if (IR_IS_CONST_REF(op1_insn->op2)) {
@@ -2490,6 +2505,44 @@ IR_FOLD(TRUNC(AND))
24902505
IR_FOLD_NEXT;
24912506
}
24922507

2508+
IR_FOLD(AND(ZEXT, C_I16))
2509+
IR_FOLD(AND(ZEXT, C_U16))
2510+
IR_FOLD(AND(ZEXT, C_I32))
2511+
IR_FOLD(AND(ZEXT, C_U32))
2512+
IR_FOLD(AND(ZEXT, C_I64))
2513+
IR_FOLD(AND(ZEXT, C_U64))
2514+
IR_FOLD(AND(ZEXT, C_ADDR))
2515+
{
2516+
ir_type src_size = ir_type_size[ctx->ir_base[op1_insn->op1].type];
2517+
2518+
if ((src_size == 1 && op2_insn->val.u64 == 0xff)
2519+
|| (src_size == 2 && op2_insn->val.u64 == 0xffff)
2520+
|| (src_size == 4 && op2_insn->val.u64 == 0xffffffff)) {
2521+
IR_FOLD_COPY(op1);
2522+
}
2523+
IR_FOLD_NEXT;
2524+
}
2525+
2526+
IR_FOLD(AND(SEXT, C_I16))
2527+
IR_FOLD(AND(SEXT, C_U16))
2528+
IR_FOLD(AND(SEXT, C_I32))
2529+
IR_FOLD(AND(SEXT, C_U32))
2530+
IR_FOLD(AND(SEXT, C_I64))
2531+
IR_FOLD(AND(SEXT, C_U64))
2532+
IR_FOLD(AND(SEXT, C_ADDR))
2533+
{
2534+
ir_type src_size = ir_type_size[ctx->ir_base[op1_insn->op1].type];
2535+
2536+
if ((src_size == 1 && op2_insn->val.u64 == 0xff)
2537+
|| (src_size == 2 && op2_insn->val.u64 == 0xffff)
2538+
|| (src_size == 4 && op2_insn->val.u64 == 0xffffffff)) {
2539+
opt = IR_OPT(IR_ZEXT, IR_OPT_TYPE(opt));
2540+
op1 = op1_insn->op1;
2541+
op2 = IR_UNUSED;
2542+
IR_FOLD_RESTART;
2543+
}
2544+
IR_FOLD_NEXT;
2545+
}
24932546
IR_FOLD(AND(SHR, C_I8))
24942547
IR_FOLD(AND(SHR, C_U8))
24952548
{

ext/opcache/jit/ir/ir_sccp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ static bool ir_sccp_remove_unfeasible_merge_inputs(ir_ctx *ctx, ir_ref ref, ir_i
927927
IR_ASSERT(insn->op == IR_MERGE || insn->op == IR_LOOP_BEGIN);
928928
old_merge_inputs = insn->inputs_count;
929929
new_merge_inputs = 0;
930-
life_inputs = (old_merge_inputs - IR_BITSET_BITS) ? &holder : ir_bitset_malloc(old_merge_inputs + 1);
930+
life_inputs = (old_merge_inputs < IR_BITSET_BITS) ? &holder : ir_bitset_malloc(old_merge_inputs + 1);
931931

932932
for (i = 1; i <= old_merge_inputs; i++) {
933933
ir_ref input = ir_insn_op(insn, i);
@@ -3328,6 +3328,10 @@ static ir_ref ir_iter_optimize_condition(ir_ctx *ctx, ir_ref control, ir_ref con
33283328
condition_insn = &ctx->ir_base[condition];
33293329
}
33303330

3331+
if (condition_insn->op == IR_ALLOCA || condition_insn->op == IR_VADDR) {
3332+
return IR_TRUE;
3333+
}
3334+
33313335
if (!IR_IS_CONST_REF(condition) && ctx->use_lists[condition].count > 1) {
33323336
condition = ir_check_dominating_predicates(ctx, control, condition);
33333337
}

0 commit comments

Comments
 (0)