Skip to content

promote function parameters to i64 when integer-eligible#478

Merged
cs01 merged 3 commits intomainfrom
param-i64-promotion
Mar 19, 2026
Merged

promote function parameters to i64 when integer-eligible#478
cs01 merged 3 commits intomainfrom
param-i64-promotion

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Mar 19, 2026

Summary

  • Numeric function params (like lo, hi in quicksort) are now promoted to i64 when integer analysis determines they're only used in integer contexts
  • Eliminates sitofp i64→double + fcmp conversions on every loop iteration, replacing them with pure icmp i64 comparisons
  • Extends the existing local variable i64 optimization (PR optimize bounds checks: unsigned compare + noreturn #475) to function parameters

Test plan

  • New test fixture tests/fixtures/optimization/param-i64-promotion.ts (quicksort)
  • All existing tests pass
  • Self-hosting verification passes

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 19, 2026

Benchmark Results (Linux x86-64)

Benchmark C ChadScript Go Node Bun Place
Binary Trees 1.267s 1.647s 3.004s 1.516s 1.215s #4
Cold Start 0.6ms 0.6ms 1.3ms 21.8ms 7.6ms 🥇
Fibonacci 0.725s 1.424s 1.429s 2.842s 1.837s 🥈
File I/O 0.088s 0.089s 0.088s 0.315s 0.204s 🥉
JSON Parse/Stringify 0.004s 0.005s 0.016s 0.015s 0.007s 🥈
Matrix Multiply 0.373s 0.648s 0.448s 0.413s 0.444s #5
Monte Carlo Pi 0.400s 0.398s 0.405s 1.474s 6.428s 🥇
N-Body Simulation 1.453s 1.852s 1.964s 2.296s 2.817s 🥈
Quicksort 0.170s 0.202s 0.184s 0.249s 0.205s 🥉
SQLite 0.314s 0.374s 0.437s 0.371s 🥉
Sieve of Eratosthenes 0.027s 0.038s 0.033s 0.054s 0.049s 🥉
String Manipulation 0.008s 0.039s 0.017s 0.037s 0.028s #5

@cs01 cs01 merged commit 863745b into main Mar 19, 2026
13 checks passed
@cs01 cs01 deleted the param-i64-promotion branch March 19, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant