Skip to content

Commit bad5d2c

Browse files
committed
Update IR
IR commit: ae34ae52b7b1c359afa03a0a1f45cbf689a64471
1 parent 3626e2d commit bad5d2c

File tree

8 files changed

+1225
-934
lines changed

8 files changed

+1225
-934
lines changed

ext/opcache/jit/ir/ir.c

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,22 +1860,30 @@ static ir_ref ir_find_aliasing_load(ir_ctx *ctx, ir_ref ref, ir_type type, ir_re
18601860
while (ref > limit) {
18611861
insn = &ctx->ir_base[ref];
18621862
if (insn->op == IR_LOAD) {
1863-
if (insn->type == type && insn->op2 == addr) {
1864-
return ref; /* load forwarding (L2L) */
1863+
if (insn->op2 == addr) {
1864+
if (insn->type == type) {
1865+
return ref; /* load forwarding (L2L) */
1866+
} else if (ir_type_size[insn->type] == ir_type_size[type]) {
1867+
return ir_fold1(ctx, IR_OPT(IR_BITCAST, type), ref); /* load forwarding with bitcast (L2L) */
1868+
} else if (ir_type_size[insn->type] > ir_type_size[type]
1869+
&& IR_IS_TYPE_INT(type) && IR_IS_TYPE_INT(insn->type)) {
1870+
return ir_fold1(ctx, IR_OPT(IR_TRUNC, type), ref); /* partial load forwarding (L2L) */
1871+
}
18651872
}
18661873
} else if (insn->op == IR_STORE) {
18671874
ir_type type2 = ctx->ir_base[insn->op3].type;
18681875

18691876
if (insn->op2 == addr) {
1870-
if (type2 == type) {
1871-
ref = insn->op3;
1872-
insn = &ctx->ir_base[ref];
1873-
if (insn->op == IR_RLOAD && (modified_regset & (1 << insn->op2))) {
1874-
/* anti-dependency */
1875-
return IR_UNUSED;
1876-
}
1877-
return ref; /* store forwarding (S2L) */
1878-
} else if (IR_IS_TYPE_INT(type) && ir_type_size[type2] > ir_type_size[type]) {
1877+
if (ctx->ir_base[insn->op3].op == IR_RLOAD
1878+
&& (modified_regset & (1 << ctx->ir_base[insn->op3].op2))) {
1879+
/* anti-dependency */
1880+
return IR_UNUSED;
1881+
} else if (type2 == type) {
1882+
return insn->op3; /* store forwarding (S2L) */
1883+
} else if (ir_type_size[type2] == ir_type_size[type]) {
1884+
return ir_fold1(ctx, IR_OPT(IR_BITCAST, type), insn->op3); /* store forwarding with bitcast (S2L) */
1885+
} else if (ir_type_size[type2] > ir_type_size[type]
1886+
&& IR_IS_TYPE_INT(type) && IR_IS_TYPE_INT(type2)) {
18791887
return ir_fold1(ctx, IR_OPT(IR_TRUNC, type), insn->op3); /* partial store forwarding (S2L) */
18801888
} else {
18811889
return IR_UNUSED;
@@ -2664,6 +2672,43 @@ void _ir_AFREE(ir_ctx *ctx, ir_ref size)
26642672

26652673
ir_ref _ir_VLOAD(ir_ctx *ctx, ir_type type, ir_ref var)
26662674
{
2675+
ir_ref ref = ctx->control;
2676+
ir_insn *insn;
2677+
2678+
while (ref > var) {
2679+
insn = &ctx->ir_base[ref];
2680+
if (insn->op == IR_VLOAD) {
2681+
if (insn->op2 == var) {
2682+
if (insn->type == type) {
2683+
return ref; /* load forwarding (L2L) */
2684+
} else if (ir_type_size[insn->type] == ir_type_size[type]) {
2685+
return ir_fold1(ctx, IR_OPT(IR_BITCAST, type), ref); /* load forwarding with bitcast (L2L) */
2686+
} else if (ir_type_size[insn->type] > ir_type_size[type]
2687+
&& IR_IS_TYPE_INT(type) && IR_IS_TYPE_INT(insn->type)) {
2688+
return ir_fold1(ctx, IR_OPT(IR_TRUNC, type), ref); /* partial load forwarding (L2L) */
2689+
}
2690+
}
2691+
} else if (insn->op == IR_VSTORE) {
2692+
ir_type type2 = ctx->ir_base[insn->op3].type;
2693+
2694+
if (insn->op2 == var) {
2695+
if (type2 == type) {
2696+
return insn->op3; /* store forwarding (S2L) */
2697+
} else if (ir_type_size[type2] == ir_type_size[type]) {
2698+
return ir_fold1(ctx, IR_OPT(IR_BITCAST, type), insn->op3); /* store forwarding with bitcast (S2L) */
2699+
} else if (ir_type_size[type2] > ir_type_size[type]
2700+
&& IR_IS_TYPE_INT(type) && IR_IS_TYPE_INT(type2)) {
2701+
return ir_fold1(ctx, IR_OPT(IR_TRUNC, type), insn->op3); /* partial store forwarding (S2L) */
2702+
} else {
2703+
break;
2704+
}
2705+
}
2706+
} else if (insn->op == IR_MERGE || insn->op == IR_LOOP_BEGIN || insn->op == IR_CALL || insn->op == IR_STORE) {
2707+
break;
2708+
}
2709+
ref = insn->op1;
2710+
}
2711+
26672712
IR_ASSERT(ctx->control);
26682713
return ctx->control = ir_emit2(ctx, IR_OPT(IR_VLOAD, type), ctx->control, var);
26692714
}

ext/opcache/jit/ir/ir_aarch64.dasc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -982,9 +982,7 @@ binop_fp:
982982
} else if ((ir_op_flags[op_insn->op] & IR_OP_FLAG_COMMUTATIVE)
983983
&& ctx->ir_base[op_insn->op2].op == IR_RLOAD
984984
&& ctx->ir_base[op_insn->op2].op2 == insn->op3) {
985-
ir_ref tmp = op_insn->op1;
986-
op_insn->op1 = op_insn->op2;
987-
op_insn->op2 = tmp;
985+
SWAP_REFS(op_insn->op1, op_insn->op2);
988986
ctx->rules[insn->op2] = IR_FUSED | IR_BINOP_INT;
989987
ctx->rules[op_insn->op1] = IR_SKIPPED | IR_RLOAD;
990988
return IR_REG_BINOP_INT;

0 commit comments

Comments
 (0)