Skip to content

Commit 90d0706

Browse files
committed
Merge SCCP value comparison into a single sccp_values_differ() callback
1 parent 8d8da71 commit 90d0706

1 file changed

Lines changed: 11 additions & 15 deletions

File tree

‎Zend/Optimizer/sccp.c‎

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,25 +1946,21 @@ static void sccp_mark_feasible_successors(
19461946
scdf_mark_edge_feasible(scdf, block_num, block->successors[s]);
19471947
}
19481948

1949-
static bool sccp_is_identical(const zval *a, const zval *b);
1950-
1951-
/* Returns int to be compatible with compare_func_t. */
1952-
static int sccp_is_not_identical(const zval *a, const zval *b)
1949+
/* Unlike zend_is_identical(), this does not treat 0.0 and -0.0 as the same value.
1950+
* Returns int to be usable as compare_func_t. */
1951+
static int sccp_values_differ(const void *p1, const void *p2)
19531952
{
1954-
return !sccp_is_identical(a, b);
1955-
}
1953+
const zval *a = p1;
1954+
const zval *b = p2;
19561955

1957-
/* Unlike zend_is_identical(), this does not treat 0.0 and -0.0 as the same value. */
1958-
static bool sccp_is_identical(const zval *a, const zval *b)
1959-
{
19601956
if (Z_TYPE_P(a) == IS_DOUBLE && Z_TYPE_P(b) == IS_DOUBLE) {
1961-
return memcmp(&Z_DVAL_P(a), &Z_DVAL_P(b), sizeof(double)) == 0;
1957+
return memcmp(&Z_DVAL_P(a), &Z_DVAL_P(b), sizeof(double)) != 0;
19621958
}
19631959
if (Z_TYPE_P(a) == IS_ARRAY && Z_TYPE_P(b) == IS_ARRAY) {
1964-
return Z_ARRVAL_P(a) == Z_ARRVAL_P(b)
1965-
|| zend_hash_compare(Z_ARRVAL_P(a), Z_ARRVAL_P(b), (compare_func_t) sccp_is_not_identical, 1) == 0;
1960+
return Z_ARRVAL_P(a) != Z_ARRVAL_P(b)
1961+
&& zend_hash_compare(Z_ARRVAL_P(a), Z_ARRVAL_P(b), sccp_values_differ, 1) != 0;
19661962
}
1967-
return zend_is_identical(a, b);
1963+
return !zend_is_identical(a, b);
19681964
}
19691965

19701966
static void join_hash_tables(HashTable *ret, HashTable *ht1, HashTable *ht2)
@@ -1979,7 +1975,7 @@ static void join_hash_tables(HashTable *ret, HashTable *ht1, HashTable *ht2)
19791975
} else {
19801976
val2 = zend_hash_index_find(ht2, index);
19811977
}
1982-
if (val2 && sccp_is_identical(val1, val2)) {
1978+
if (val2 && !sccp_values_differ(val1, val2)) {
19831979
if (key) {
19841980
val1 = zend_hash_add_new(ret, key, val1);
19851981
} else {
@@ -2047,7 +2043,7 @@ static void join_phi_values(zval *a, zval *b, bool escape) {
20472043
zval_ptr_dtor_nogc(a);
20482044
MAKE_BOT(a);
20492045
}
2050-
} else if (sccp_is_not_identical(a, b)) {
2046+
} else if (sccp_values_differ(a, b)) {
20512047
if (join_partial_arrays(a, b) == FAILURE) {
20522048
zval_ptr_dtor_nogc(a);
20532049
MAKE_BOT(a);

0 commit comments

Comments
 (0)