Skip to content

agx: restore trivial phi elimination after spilling on every chip - #549

Merged
RyanTheTide merged 1 commit into
aurora-wipfrom
sweep/bugfix-gates
Nov 19, 2026
Merged

RyanTheTide merged 1 commit into
aurora-wipfrom
sweep/bugfix-gates

Conversation

@RyanTheTide

Copy link
Copy Markdown

Problem

Upstream e4520b1 added a constant-source check to trivial-phi elimination in SSA repair and dropped a !, so the pass skipped every phi on every chip. 36bdc21 / f6835fb restored it only for G17P and M5.

Change

Restore the condition on every chip. The pass only compares phi sources and rewrites uses; nothing in it depends on the ISA, register file or encoding. The constant-source check still comes first, so the remap[] overread e4520b1 fixed stays fixed. G17PRemovesTrivialJoinPhi becomes RemovesTrivialJoinPhi and checks G13G, G17P and G17S keys.

libagx: 593 of 599 kernels byte-identical; the six that change all shrink and are G15/G16 targets (libagx_tess_tri_1 9415 -> 7005 words, libagx_tess_quad_1 10930 -> 9647 on g15s/g15g/g16g). g13g, g13x, g17p, g17g and g18g kernels are unchanged.

Testing

Newly reaches the M1 Pro and M2 (G17P and M5 already had the fix). Rows:

Hardware rows used one combined build of all sweep branches (sweep/all5 = aurora-wip c55152d + this and the sibling sweep branches) against aurora-wip c55152d, both gcc release builds with identical meson options, loaded as user-space overlays (VK_DRIVER_FILES / LD_LIBRARY_PATH) on the production kernels; nothing installed, no reboot.

machine (GPU) kernel dEQP-VK subset, 14,869 cases GLES/GL CTS subset, 5,079 cases gpubench-vk (2 interleaved runs per arm)
A18 Pro MacBook Neo (G17P) 7.3.0-40 11262 Pass / 3607 NotSupported / 0 Fail, 0 changed 4975 Pass, 0 changed all rows within run-to-run spread (single-submit rows rechecked with 4 runs)
M4 Pro (G17P) 7.3.0-aurora-fleet75 11262 Pass / 3607 NotSupported / 0 Fail, 0 changed 4975 Pass, 0 changed all rows flat except the queue timeline hop (16.1/17.5 vs 19.2/20.0 us); that row is bimodal, no branch touches its path on the M4 Pro, and it is flat on the A18 Pro; a 5-run recheck is pending
M2 (G14G) 7.3.0-aurora-fleet74 7946 Pass / 6523 NotSupported / 0 Fail, 0 changed (sweep/all4) n/a all rows within +-2 % except render.light d1, bimodal (194-222 us) in both arms
M1 Pro (G13S) 7.3.0-aurora-fleet74 16,864-case variant of the subset (adds pipeline sample_mask/timestamp and image load/store): 9571 Pass / 7293 NotSupported / 0 Fail, 0 changed 4023 Pass, 0 changed flat except compute.heavy alu d1: 5-run recheck 1101-1163 vs 1121-1196 us (median +4.7 %); d4/d16 identical, the same row is identical on the M2 (same AGX2 compiler path) and flat in a clang-built pair on this Mac, so most likely run-state noise; a per-branch isolation is still to run
Method
  • dEQP-VK subset (Vulkan CTS 1.4.7.0): compute.pipeline., synchronization(2).op.single_queue.{barrier,event,timeline_semaphore}., synchronization.timeline_semaphore., synchronization.global_priority_transition., api.device_init.create_device_global_priority*, memory_model.{message_passing,shared}., ssbo(.phys).layout.random., glsl.{opaque_type_indexing,operator,loops}., spirv_assembly.instruction.{graphics.16bit_storage,compute.float_controls}., api.copy_and_blit buffer/image copies, clipping.user_defined., query_pool.statistics_query.fragment_shader_invocations., tessellation.{primitive_discard,winding,shader_input_output}.* (large groups subsampled 1/2 to 1/8).
  • GLES/GL: every second case of a 13k dEQP-GLES2/3/31 + KHR-GL46 list (shaders, texture, fbo, ssbo, copy_image, fragment_ops, ubo, packed_pixels).
  • gpubench-vk 0dae261: submit.empty, compute.light, render.light, copy.bw {buf2buf, buf2img, fill}, sync.signal {queue timeline, host}, compute.heavy {alu, bw}, render.heavy fill 1080p/2160p, query timestamp; --warmup-ms 300 --runs 5 --run-ms 250, arms interleaved, 70 C cool-down gate.
  • Kernel log, GPU fault count, failed units and AVCs checked before and after each run: no new entries.

Still to run

dEQP-VK.tessellation.* on a G15/G16 machine (the only libagx kernels that change).

Fixes: e4520b1 ("agx: fix SSA repair with phis with constants"). Builds on 36bdc21 and f6835fb (Diljit Singh).

Assisted-by: LLM (Claude:Opus 5.5)

agx_opt_trivial_phi() must skip a phi whose source was itself remapped
in the current round (the cycle case it does not handle). e4520b1
("agx: fix SSA repair with phis with constants") added the
constant-source check in front of that test and dropped its negation, so
the pass skipped every phi whose source had not been remapped -- on the
first round, all of them -- and removed nothing. f6835fb and
36bdc21 restored the negation, but only for G17P and the M5 family,
leaving every other chip on the broken test.

The pass runs on AIR after the spiller's SSA repair. It only compares
phi sources and rewrites uses; it does not depend on the ISA encoding,
the register file or any per-chip hardware behaviour. The restored
condition is the one every chip ran before e4520b1, and the
constant-source check that commit added still comes first, so remap[] is
indexed only by normal SSA values and the overread it fixed stays fixed.
Make the corrected test unconditional, which brings AGX2 (G13/G14), G15,
G16 and G18G to the code G17P and M5 already use.

The host test now expects the trivial join phi to be removed for an AGX2,
an AGX3B and an AGX3C key alike.

x86: 138/138 asahi unit tests pass (baseline 138/138). Of the 599
precompiled libagx kernels, 593 are byte-identical to aurora-wip. The
six that change are the spilling tessellator kernels for the G15S, G15G
and G16G targets: tess_tri_1 goes from 9415 to 7005 words and
tess_quad_1 from 10930 to 9647, because their trivial phis no longer
become copies. The G13G, G13X, G17P, G17G and G18G kernels are
unchanged.

Builds on 36bdc21 and f6835fb by DjDeveloperr.

Fixes: e4520b1 ("agx: fix SSA repair with phis with constants")
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide
RyanTheTide merged commit e6ee1e0 into aurora-wip Nov 19, 2026
@RyanTheTide
RyanTheTide deleted the sweep/bugfix-gates branch November 27, 2026 13:21
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