]> granicus.if.org Git - php/commitdiff
Optimize out usless conditions used by specializer
authorDmitry Stogov <dmitry@zend.com>
Thu, 25 Jun 2015 15:56:14 +0000 (18:56 +0300)
committerDmitry Stogov <dmitry@zend.com>
Thu, 25 Jun 2015 15:56:14 +0000 (18:56 +0300)
Zend/zend_execute.h
Zend/zend_portability.h

index 9719eda42b749e5bdca1e24a533c0db3347c2797..f595edca9bc78e8ed78588593a27c1f7e8a8fc75 100644 (file)
@@ -58,7 +58,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
 {
        zend_refcounted *ref = NULL;
 
-       if ((value_type & (IS_VAR|IS_CV)) && Z_ISREF_P(value)) {
+       if (ZEND_CONST_COND(value_type & (IS_VAR|IS_CV), 1) && Z_ISREF_P(value)) {
                ref = Z_COUNTED_P(value);
                value = Z_REFVAL_P(value);
        }
@@ -78,7 +78,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
                                Z_OBJ_HANDLER_P(variable_ptr, set)(variable_ptr, value);
                                return variable_ptr;
                        }
-                       if ((value_type & (IS_VAR|IS_CV)) && variable_ptr == value) {
+                       if (ZEND_CONST_COND(value_type & (IS_VAR|IS_CV), 1) && variable_ptr == value) {
                                return variable_ptr;
                        }
                        garbage = Z_COUNTED_P(variable_ptr);
@@ -93,7 +93,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
                                        if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) {
                                                Z_ADDREF_P(variable_ptr);
                                        }
-                               } else if (/* value_type == IS_VAR && */ UNEXPECTED(ref)) {
+                               } else if (ZEND_CONST_COND(value_type == IS_VAR, 1) && UNEXPECTED(ref)) {
                                        if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
                                                efree_size(ref, sizeof(zend_reference));
                                        } else if (Z_OPT_REFCOUNTED_P(variable_ptr)) {
@@ -122,7 +122,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
                if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) {
                        Z_ADDREF_P(variable_ptr);
                }
-       } else if (/* value_type == IS_VAR && */ UNEXPECTED(ref)) {
+       } else if (ZEND_CONST_COND(value_type == IS_VAR, 1) && UNEXPECTED(ref)) {
                if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
                        efree_size(ref, sizeof(zend_reference));
                } else if (Z_OPT_REFCOUNTED_P(variable_ptr)) {
index 8c6989d03028a9eb6eaa0478863e85da430416c9..214ece53e65336937b358cba4dabda911325d869 100644 (file)
@@ -250,6 +250,14 @@ char *alloca();
 # define HAVE_BUILTIN_CONSTANT_P
 #endif
 
+#ifdef HAVE_BUILTIN_CONSTANT_P
+# define ZEND_CONST_COND(_condition, _default) \
+       (__builtin_constant_p(_condition) ? (_condition) : (_default))
+#else
+# define ZEND_CONST_COND(_condition, _default) \
+       (_default)
+#endif
+
 #if ZEND_DEBUG
 # define zend_always_inline inline
 # define zend_never_inline