summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2018-02-18 15:13:14 +0100
committerNikita Popov <nikita.ppv@gmail.com>2018-02-18 15:33:28 +0100
commit39974dd65d1399d917fda591b864bc09eb53b6c0 (patch)
tree3e2e087bea858adc0ff0bf071546d5ec63ea428c
parent846e8a3ec9a748642bb08dbf38923a155146a3ad (diff)
downloadphp-git-39974dd65d1399d917fda591b864bc09eb53b6c0.tar.gz
Disable negative range inference
The negative range inference implementation does not work correctly, and it's not clear right now how it can be fixed. As such, disable it entirely for now.
-rw-r--r--ext/opcache/Optimizer/zend_inference.c3
-rw-r--r--ext/opcache/tests/neg_range_inference.phpt26
2 files changed, 28 insertions, 1 deletions
diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c
index 1bfd395dd0..b5488c4dc0 100644
--- a/ext/opcache/Optimizer/zend_inference.c
+++ b/ext/opcache/Optimizer/zend_inference.c
@@ -39,7 +39,8 @@
#define SYM_RANGE
/* Whether to handle negative range constraints */
-#define NEG_RANGE
+/* Negative range inference is buggy, so disabled for now */
+#undef NEG_RANGE
/* Number of warmup passes to use prior to widening */
#define RANGE_WARMUP_PASSES 16
diff --git a/ext/opcache/tests/neg_range_inference.phpt b/ext/opcache/tests/neg_range_inference.phpt
new file mode 100644
index 0000000000..b3dd4a72be
--- /dev/null
+++ b/ext/opcache/tests/neg_range_inference.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Incorrect negative range inference
+--FILE--
+<?php
+
+function test() {
+ for ($i = 0; $i < 10; $i++) {
+ if ($i != 5) {
+ $t = (int) ($i < 5);
+ var_dump($t);
+ }
+ }
+}
+test();
+
+?>
+--EXPECT--
+int(1)
+int(1)
+int(1)
+int(1)
+int(1)
+int(0)
+int(0)
+int(0)
+int(0)