AOT: integer subtraction overflow promotes to float (#32422) - #32424
Merged
Conversation
Native-long minus wrapped with LLVM sub nsw; Zend promotes via fast_long_sub_function. Extend #31964 JitLongArithOverflow to TYPE_MINUS. Co-authored-by: Cursor <cursoragent@cursor.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
-used LLVMsub nswand wrapped (PHP_INT_MIN - 1→int(PHP_INT_MAX)). Zendsub_function/fast_long_sub_functionpromotes to double (Zend/zend_operators.h).#31964JitLongArithOverflowtoTYPE_MINUS(portable sign-bit overflow: operand signs differ and wrapping result sign differs from op1). Const-fold uses PHP native$a - $b. Folded integer constants useint64(constantFromInteger(..., 'long')is not a mapped LLVM type).runtime/*.c.Closes #32422
Test plan
./script/docker-exec.sh -- bash -lc 'export PHP_COMPILER_HELPER_RUNTIME_O=0 PHP_COMPILER_HELPER_RUNTIME_CACHE_DIR=/tmp/phpc-32422-aot-smoke; mkdir -p /tmp/phpc-32422-aot-smoke; ./script/aot-smoke.sh'./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/issue_int_sub_overflow.php'./script/docker-exec.sh -- bash -lc 'export PHP_COMPILER_HELPER_RUNTIME_O=0 PHP_COMPILER_HELPER_RUNTIME_CACHE_DIR=/tmp/phpc-32422-repro PHP_COMPILER_LLVM_ASSERT=1; mkdir -p /tmp/phpc-32422-repro; php bin/compile.php -o /tmp/iso.bin test/repro/issue_int_sub_overflow.php && /tmp/iso.bin'same four lines as VM / Zend
./script/phpunit.sh --filter 'IntSubOverflowPromote32422|IntArithOverflowPromote31964'Not covered: full
ci-local.sh/north-star5-verify --strict/ compliance suites.Made with Cursor