Skip to content

Add signed-zero arithmetic regression tests for GH-25744 - #25749

Draft
rafamolina1 wants to merge 1 commit into
php:PHP-8.4from
rafamolina1:test-gh25744-signed-zero
Draft

rafamolina1 wants to merge 1 commit into
php:PHP-8.4from
rafamolina1:test-gh25744-signed-zero

Conversation

@rafamolina1

Copy link
Copy Markdown

Adding zero to a known float can incorrectly preserve negative zero when the DFA pass replaces the arithmetic operation with a copy. This PR adds supplementary regression coverage for #25744.

Depends on #25608, which provides the optimizer fix and its initial regression test. This PR contains only the additional ext/opcache/tests/opt/gh25744.phpt test; it is a draft because the test currently fails without that fix. It can be merged after #25608 or cherry-picked into it.

The test covers both operand orders for addition, positive and negative zero constants, subtraction, negative finite operands, infinities, NaN, and integer controls. It checks zero signs through reciprocals and serialization, plus observable string and JSON results after casts and rounding. Hot functions exercise JIT configurations as well.

Validation on PHP-8.4, PHP-8.5, PHP-8.6, and master:

  • The test fails on the unpatched base and passes with the Fix GH-25744: DFA pass turning a float + 0.0 into a copy that keeps -0.0 #25608 fix, with JIT disabled, tracing JIT, and function JIT. JIT activity was confirmed through generated buffer usage.
  • Expected output matches execution with OPcache disabled and with the DFA pass disabled.
  • Zend and OPcache suites were compared before and after applying the fix together with the additional test: no new failures on any branch. PHP-8.5, PHP-8.6, and master had no failures; PHP-8.4 retained the same gh17733 and gh8739 failures as the base.

Extend the coverage accompanying php#25608 with negative operands, infinities, NaN, integer controls, reciprocal signs, and string, JSON, and serialization outputs. Exercise hot functions for JIT validation.
@rafamolina1

Copy link
Copy Markdown
Author

This PR adds supplementary tests for #25744 and depends on the optimizer fix in #25608. The test fails on the unpatched base and passes with that fix on PHP 8.4, 8.5, 8.6, and master, with JIT disabled and with tracing/function JIT.

Feel free to cherry-pick the test into #25608 if keeping the fix and coverage together is preferable.

@ChrisAbner

@ChrisAbner

Copy link
Copy Markdown
Contributor

Thanks for checking the fix on all branches. I'd rather keep #25608 with its current test. For a non-zero operand the addition and the copy give the same result, so the INF, NaN and finite cases pass with or without the fix. The JIT has no shortcut of its own for x + 0.0 either, and the existing test already runs under function JIT. I've linked #25608 to GH-25744.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants