Xu 0.16.2 Released: Phase 1–6 Optimization Batch, x86-64-v3 Codegen and the GVN Escape-Analysis Fix
Xu 0.16.2 is officially released! This release lands the Phase 1–6 compiler, MIR, codegen and runtime optimization batch (PR #323), fixes an x86-64 miscompile that the same batch introduced in the global value numbering pass (PR #325), and calibrates the Windows release gate for the new task-stack defaults (PR #327).
See the Xu 0.16.0 release notes for the preceding top-of-file const rule and optimization Batches Q–T, and inspect the updated program structure guide, OS development guide, and API reference.
1. Runtime & Standard Library
- Loop-Local Slice Capacity: MIR lowering now reuses the capacity of a slice assigned inside a loop and hoists the empty-slice capacity check out of the loop body, removing a repeated allocation and a repeated branch (
src/xu/mir/lower.xu,lower_chan.xu,lower_fnval.xu). - Stack & Buffer Discipline:
compress/lzwkeeps its working state in stack arrays instead of heap temporaries,string_reservegrows a string buffer without changing its visible length, andcopy_mem/zero_membecome runtime calls once a copy exceeds 512 bytes instead of inlining an unbounded byte loop (PR #323). - Windows I/O: the Windows netpoller now drives AFD/IOCP completion directly and wakes the M:N scheduler through the same
os/signalwakeup path, so blocked network tasks and signal handlers share one wakeup mechanism (src/runtime/core/host_win.xu,sched_netpoll.xu).
2. Codegen: x86-64-v3, ARM64, Loop Layout & SLP
- x86-64-v3: added VEX-encoded
x86-64-v3instruction selection with AVX2, FMA3 and BMI2 support, covering 128-bit FP moves, packed compares, fused multiply-add and the BMI2 shift/rotate forms (src/xu/codegen/x64_base.xu,bits.xu). - ARM64:
fcmp dN, #0.0is folded into the compare/select pair, spilled FP selects lower tofcsel, and the Wu-Larus loop analysis drives early-exit and backedge placement (arm64_base.xu,opt_cfg.xu). - Vectorization & Allocation: SLP now extracts lane groups through
MI_VEXTRACT, and the register allocator uses the FP hints that keep vector and scalar values in their preferred registers (regalloc.xu,opt_slp.xu).
3. MIR Optimization Passes
- Arithmetic & Addressing:
opt_foldsinks power-of-twoFDIVand fused multiply-add,opt_addrreassociates indexed pointer arithmetic under a pair-count guard, andopt_ifconvgeneralizes if-conversion to nested selects, multi-select chains, floating-point compares and same-address pointer stores (PR #323). - Loop Transformations: bulk slice-append loops are versioned from 1 byte to 8 byte steps with an inline fast path, branch elimination is now condition-aware about the upper offset bound, and IV-constant substitution fully unrolls loops with a proven trip count of up to 16, with constant folding of the induction variable and a GVN pass before dead-store elimination (PR #323).
- Loop Analysis: versioned-loop induction-variable dominance is cycle-free across multiple primaries, and inner version guards that are subsumed by an outer one are eliminated (PR #323).
4. Compiler Correctness: GVN Escape Analysis
The Phase 1–6 batch taught the global value numbering pass that a frame slot holding a backing-buffer pointer is disjoint from that buffer. That holds only while the slot is never aliased. As soon as a local's address escapes — its frame slot is passed to a call, stored through, or taken — a store through the buffer can land on the slot itself, and the disjointness reasoning removes a live load. On x86-64 this miscompiled #crypto/ecdh and broke the X25519 handshake with crypto/ecdh: bad input point, failing the Native macOS Intel SDK and platform seeds release gate (PR #323).
Xu 0.16.2 computes the set of locals whose address escapes and applies the frame-slot disjointness and slice-header rules only to slots that never escape. Buffer-owner bookkeeping is suppressed for values whose location is known, and frame-backed slice facts are pruned when the backing store is overwritten (PR #325).
5. Benchmarks (Verified 6-Platform v0.16.2 Run)
Measured across all 121 canonical workloads on six platforms in xulang-org/bench Actions Run #46330146722 (Xu commit eba3440c, 2026-11-30), with 0 Xu failures and 0 peer failures across 121 × 6 = 726 runs (xu_failed_cases = 0). Ratios represent Xu / best peer median (minimum across O1/O2/O3 for Clang and rustc); lower is faster:
| Platform | Coverage | vs Clang Geomean / Median (Wins) | vs rustc Geomean / Median (Wins) | vs Go Geomean / Median (Wins) | vs Swift Geomean / Median (Wins) |
|---|---|---|---|---|---|
| macOS ARM64 | 121 / 121 | 0.967× / 1.087× (39/116) | 0.854× / 1.003× (60/120) | 0.577× / 0.717× (102/121) | 0.444× / 0.574× (104/116) |
| Linux ARM64 | 121 / 121 | 0.810× / 1.015× (55/116) | 0.732× / 0.975× (67/120) | 0.508× / 0.686× (109/121) | 0.346× / 0.532× (110/114) |
| Windows ARM64 | 121 / 121 | 0.910× / 0.978× (68/116) | 0.846× / 0.939× (89/120) | 0.683× / 0.774× (115/121) | — |
| macOS x86_64 | 121 / 121 | 0.971× / 1.093× (48/116) | 0.854× / 1.007× (59/120) | 0.668× / 0.795× (85/121) | 0.391× / 0.539× (99/116) |
| Linux x86_64 | 121 / 121 | 0.852× / 1.006× (55/116) | 0.781× / 0.991× (68/120) | 0.542× / 0.735× (98/121) | 0.350× / 0.560× (100/114) |
| Windows x86_64 | 121 / 121 | 0.919× / 0.999× (59/116) | 0.859× / 0.975× (70/120) | 0.643× / 0.725× (102/121) | — |
Representative cross-domain workload medians (the parenthesis is the ratio against the best Clang O1/O2/O3 on the same platform; the full matrix is on the multi-architecture benchmark dashboard):
| Workload | macOS ARM64 | Linux ARM64 | Windows ARM64 | macOS x86_64 | Linux x86_64 | Windows x86_64 |
|---|---|---|---|---|---|---|
startup | 5.56 ms (1.86×) | 0.37 ms (0.59×) | 14.56 ms (0.96×) | 4.43 ms (0.63×) | 0.34 ms (0.47×) | 7.03 ms (0.88×) |
loop_sum | 4.14 ms (0.38×) | 0.39 ms (0.03×) | 14.96 ms (0.53×) | 8.86 ms (0.60×) | 0.23 ms (0.04×) | 7.22 ms (0.44×) |
fib | 23.01 ms (1.13×) | 10.98 ms (0.86×) | 25.04 ms (0.94×) | 25.99 ms (0.96×) | 17.64 ms (1.12×) | 24.12 ms (1.00×) |
matmul | 9.31 ms (0.83×) | 6.27 ms (0.70×) | 20.51 ms (0.96×) | 14.07 ms (0.95×) | 8.06 ms (1.07×) | 14.46 ms (1.00×) |
sieve_primes | 14.16 ms (0.80×) | 14.76 ms (1.06×) | 25.99 ms (0.99×) | 50.88 ms (1.18×) | 15.69 ms (1.03×) | 24.24 ms (0.99×) |
sha256_chain | 3.89 ms (0.64×) | 0.65 ms (0.37×) | 15.21 ms (0.89×) | 14.08 ms (1.37×) | 0.60 ms (0.34×) | 7.47 ms (0.82×) |
aes128_encrypt | 5.22 ms (0.13×) | 1.99 ms (0.08×) | 16.10 ms (0.35×) | 9.24 ms (0.18×) | 1.56 ms (0.09×) | 9.47 ms (0.20×) |
scimark_fft | 13.74 ms (1.50×) | 5.89 ms (1.20×) | 20.72 ms (1.04×) | 11.43 ms (1.12×) | 4.85 ms (1.37×) | 12.97 ms (1.13×) |
btree_index | 24.16 ms (0.89×) | 21.84 ms (1.13×) | 35.67 ms (1.04×) | 35.49 ms (1.10×) | 23.00 ms (0.93×) | 32.32 ms (0.85×) |
sql_query_exec | 41.25 ms (1.09×) | 34.62 ms (1.28×) | 47.56 ms (1.17×) | 60.40 ms (1.20×) | 39.84 ms (1.23×) | 55.56 ms (1.29×) |
expr_bytecode_vm | 17.06 ms (1.33×) | 11.26 ms (1.15×) | 26.05 ms (1.04×) | 23.48 ms (0.50×) | 7.31 ms (1.08×) | 25.08 ms (1.10×) |
chan_ping | 15.22 ms | 26.32 ms | 48.36 ms | 21.61 ms | 18.68 ms | 32.93 ms |
6. Upgrade & Downloads
Upgrade compiler, standard library, and SDK tools together from the Download center or GitHub Releases v0.16.2, and verify SHA256SUMS. This release changes no language syntax and no module manifest contract, so existing programs continue to compile unchanged; rebuild the toolchain as a whole so the compiler, standard library and SDK tools stay in sync.