Commit Graph
12 Commits
Author SHA1 Message Date
waozi d2db9d35fe Extend verified direct assembly execution and optimization 2026-11-11 21:28:27 -03:00
waozi 4dc2da6b09 Publish measured desktop, Android and web target matrix
Compare five real examples across four targets on three measured platforms, preserving raw samples, independent output verification and artifact provenance.

Complete the WebAssembly support needed by the examples, inspect ZX bundles, prune generated C dependencies while preserving C++ linkage, and validate native script execution. Optimize only the temporary bootstrap seed and retain fresh-build measurements and historical benchmark records under bench/results.

Local tests: all 522 cases passed across the full run and corrected header-test rerun; all 16 bootstrap modules match. Playground runtime, bundle runtime, private browser layouts and matrix controls, published artifacts and local site links passed.
2026-11-10 23:50:12 -03:00
waozi cbc9e2d3ab Test a computed range bound once and leave the loop at its last value
A range over a computed bound was emitted as `while (i <= last)` with a
second exit, `if (i == last) break;`, before its step, so GCC refused to
vectorize it ("can't vectorize early exit"). When the counter and bound
are locals declared just before the loop, nothing takes their address and
every change of the counter is a step guarded by that last-value test, the
counter can never pass the bound, and C now writes
`if (i <= last) for (;;)`: one exit, which GCC can vectorize or turn into
memset, and TinyCC no longer tests the bound in every iteration.

AV1 1080p q40 decode (same hashes): gcc -O2 89 -> 86-88 ms, -O0 340 ->
335 ms, ziran run 609 -> 605 ms, -O3 unchanged at 77-79 ms.
2026-11-06 20:14:29 -03:00
waozi f0e2e2fcfa Emit calls of small same-module procedures as their bodies in C
TinyCC never inlines, so under `ziran run` every call of a tiny helper
paid a full call with all its locals on the stack. Generated C now writes
a call of a small straight-line procedure of the same module (no loops,
no module variables, scalars, pointers and small records only) as its
body in a block: arguments still run once, left to right, a return jumps
past the body, and the inlined call still costs the step its entry did.
Calls of foreign procedures stay out of inlined bodies, and private
procedures are declared ZIRAN_MAYBE_UNUSED for when every caller inlined
them.

A 1080p AV1 decode runs about 7% faster under `ziran run` and 4% faster
at -O0 with the same output; -O3 is unchanged. The bootstrap C is
regenerated. tests/call_site_inlining.sh covers argument order, name
clashes, early returns and the warning-free build.
2026-11-06 19:03:21 -03:00
waozi e834d1ccfe Prove two-dimensional indexes from guards
Generated C leaves out the bounds check of an index such as
row * stride + column when a guard bounds it: an earlier if that returns,
breaks or continues, an enclosing if or while condition, or the earlier
operands of && and ||, until a value they compare changes. Indexes and
guard comparisons become polynomials over parameters, invariant locals
and slice counts; each loop counter is replaced by its upper bound, and
the index is proven below the count or length when every step is exact.
Guards that miss the read, values moved after the guard and else-if
exits keep their checks.

On the AV1 benchmark (fixed binaries, interleaved, one core) 1080p q20
drops from 185.1 to 182.2 ms and 720p 4:4:4 is unchanged, but 1080p
10-bit q30 rises from 201.5 to 212 ms. All of that comes from the one
check left out of FindCdefDirection's sample read; the function alone runs
faster without it (102 against 105 ns per call), so the loss is a layout
effect in the decoder's context.
2026-11-06 12:41:04 -03:00
waozi f3202b3d66 Leave out bounds checks generated C proves always pass 2026-11-06 07:37:16 -03:00
waozi 320637d835 Keep final short-circuit calls in native C expressions 2026-10-23 15:50:56 -03:00
waozi 244f36d7b0 Omit redundant C operand snapshots and regenerate bootstrap seeds 2026-10-23 15:47:12 -03:00
waozi ca0f6c2940 Reduce generated native runtime header dependencies 2026-10-15 22:21:02 -03:00
waozi bf880017f8 Avoid redundant aggregate temporaries and preserve value arguments 2026-10-02 04:44:41 -03:00
waozi 12d57b8ac1 Parse foreign declarations and conditional headers in Ziran 2026-10-01 14:15:01 -03:00
waozi 938f42b8e2 Parse loop headers and using modifiers in Ziran 2026-10-01 13:45:14 -03:00