Skip to content

AOT: native double widen for float locals — mandelbrot 248k→121k IR (#36407) - #36428

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-36407-mandelbrot-perf
Sep 2, 2026
Merged

AOT: native double widen for float locals — mandelbrot 248k→121k IR (#36407)#36428
PurHur merged 1 commit into
masterfrom
agent/issue-36407-mandelbrot-perf

Conversation

@PurHur

@PurHur PurHur commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #36407.

Untyped locals widened on float assign were promoted to heap __value__ boxes (#23471), forcing every float op in mandelbrot() through JitValueNumeric dispatch. This caused ~248k LLVM IR lines, runtime thrashing (>60s timeout on Sep 2), and a 1.66× Zend ratio.

When the widening assign is TYPE_NATIVE_DOUBLE or a compile-time float literal, promote to TYPE_NATIVE_DOUBLE (double alloca) instead. Non-numeric TYPE_VALUE assigns still use the full value box.

Verification

./script/phpunit.sh --filter float_widen_mul_escape
# OK (1 test, 5 assertions)

./script/aot-smoke.sh
# aot-smoke: 9 passed, 0 failed

script/bench-gate.sh (pinned image):
# mandelbrot  zend=0.0563  aot=0.0096  ratio=0.1704  ir_lines=121001 (was 248707)
# simple      zend=0.0279  aot=0.1400  ratio=5.0187  (≤0.25s threshold met)
# bench-gate still red on fibo(30).ratio only (pre-existing; baseline note #36189)

make dev-verify-fast — tier 0f gen-0 smoke OK; tier 1 aot-smoke blocked by CI lock (ran separately above)

Not covered this run: full script/differential-sweep.sh --aot --repeat 3 (CI lock held by parallel workspace run).

php-src reference

Zend keeps IS_LONG on the fast path and only materialises IS_DOUBLE on overflow (Zend/zend_operators.h fast_long_add_function). This change mirrors that for untyped locals: stay native double once widened, box only when the assign requires full polymorphism.

Made with Cursor

Untyped locals promoted on float assign used heap __value__ boxes, forcing
every float op in mandelbrot through JitValueNumeric dispatch (~248k IR,
1.66× Zend). Promote to TYPE_NATIVE_DOUBLE when the assign is a native
double or a compile-time float literal; keep __value__ for other types.

Verified: float_widen_mul_escape.phpt green; mandelbrot IR 121k (−51%);
bench-gate mandelbrot 0.0096s ratio 0.17; aot-smoke 9/9.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit fe485dd into master Sep 2, 2026
1 check failed
@PurHur
PurHur deleted the agent/issue-36407-mandelbrot-perf branch September 2, 2026 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant