Skip to content

Commit 8f5156f

Browse files
committed
Fixed trace type inference
1 parent 26b4130 commit 8f5156f

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,6 +1862,14 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin
18621862
ADD_OP1_TRACE_GUARD();
18631863
}
18641864
break;
1865+
case ZEND_ADD:
1866+
case ZEND_SUB:
1867+
case ZEND_MUL:
1868+
// case ZEND_DIV: // TODO: check for division by zero ???
1869+
if (orig_op1_type == IS_UNDEF || orig_op2_type == IS_UNDEF) {
1870+
break;
1871+
}
1872+
ZEND_FALLTHROUGH;
18651873
case ZEND_IS_EQUAL:
18661874
case ZEND_IS_NOT_EQUAL:
18671875
case ZEND_IS_SMALLER:
@@ -1876,10 +1884,6 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin
18761884
case ZEND_SL:
18771885
case ZEND_SR:
18781886
case ZEND_MOD:
1879-
case ZEND_ADD:
1880-
case ZEND_SUB:
1881-
case ZEND_MUL:
1882-
// case ZEND_DIV: // TODO: check for division by zero ???
18831887
ADD_OP2_TRACE_GUARD();
18841888
ZEND_FALLTHROUGH;
18851889
case ZEND_ECHO:

ext/opcache/tests/jit/add_015.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
JIT ADD: 014 incorrect guard elimination
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
--FILE--
7+
<?php
8+
function test() {
9+
$j = 0;
10+
for ($i = 0; $i < 41; $i++) {
11+
$a &= $a &= $aZ - $a;
12+
$aZ = $a;
13+
$a &= $a &= $aZ = $a;
14+
$aZ = $a;
15+
$a = &$a + $e = $a-- +$a &= $a &= $a &= $aZ = $a;
16+
}
17+
}
18+
@test();
19+
?>
20+
DONE
21+
--EXPECT--
22+
DONE

0 commit comments

Comments
 (0)