Repository navigation
asahi: sink matching shared stores with identical access qualifiers - #1538
Conversation
Carry the shared-store portion of 8e2d121 onto current trunk. Match terminal stores in if/else diamonds and retain one store after the merge. Signed-off-by: DjDeveloperr <hey@djdev.me> Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Require equal qualifiers on both stores. Intersecting the flags could remove coherent access on one arm. Cover that mismatch in the existing rejection test. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
satchlj
left a comment
There was a problem hiding this comment.
Reviewed 2290bdbf0116 (asahi: sink matching shared stores with identical access qualifiers):
- Both items from
#1537are cleanly addressed:6dc29e25d358preserves Dj's authorship andSigned-off-by:trailer above Ryan's, and2290bdbf0116requiresnir_intrinsic_access(ts) == nir_intrinsic_access(es)(still rejectingACCESS_VOLATILE | ACCESS_ATOMIC) and preservesaccesson the sunknir_store_sharedwithout dropping requirement qualifiers likeACCESS_COHERENT. RefusesToSinkMismatchedSharedStorescovers mismatched offsets, volatile stores, andACCESS_COHERENTvs ordinary mismatches, alongsideSinkCommonStoreSharedcovering commuted address expressions and NIR validation.- Exact-head verification (
1,955Asahi compiler tests with 0 failures, AArch64 ICD builds, 44 policy self-tests, and J615 M3 Air paired ABBA/BAAB correctness + shader dump confirming 2 -> 1 shared store) and## Riskare clean.
LGTM.
|
Exact-head M5 Max (
|
There was a problem hiding this comment.
Verdict: MERGE at 2290bdb
Checked: an exact-head x86-64 assert-enabled build (-Db_ndebug=false -Dbuild-tests=true, drm-shim, asahi Gallium + Vulkan) with meson test --suite asahi --suite poly gave 393 OK, 0 fail, 1 skip. That includes agx_tests with SinkCommonStoreShared and RefusesToSinkMismatchedSharedStores. Mesa has no Actions CI, so this local run is the CI record. Code points I worked through:
- Both stores are each arm's last instruction, and the new store goes at
nir_after_phisof the merge block, so nothing runs between the old and new store positions. Moving the store past reconvergence changes nothing. same_pure_expradmits only load_const/ALU trees whose leaves dominate the if. Matching includes swizzles, fp_math_ctrl and nsw/nuw, and commuted integer ops.clone_pure_exprhoists the then-arm tree before the if, andnir_instr_clone_deepleaves out-of-arm sources unmapped, so they stay as they are. Pure ALU speculation is safe.- Access must be equal and must not include VOLATILE/ATOMIC. base, write_mask, alignment and value/address sizes must match, so the coherent mismatch case refuses.
- Lanes in different arms writing the same address with no barrier race in both the old and new code, so no observable order changes.
Follow-ups: none blocking.
Supersedes #1537 and carries the shared-store part of #761 onto current
aurora-wip. Dj's original authorship and sign-off are carried in the extraction commit. The follow-up requires identical access qualifiers throughout the diamond, so sinking cannot drop a coherent access requirement from either arm. Both original qualifiers are preserved in the retained store.The existing host fixture covers matching and commuted addresses, different addresses, volatile stores, and the new coherent versus ordinary mismatch. The remaining optimizer changes are tracked in #1535 and #1536.
Tested
Exact head
2290bdbf011619df325d839686f2b58ff95027a9versus trunk93ce24cda24ba73ef0a80a5c15787fa9edbbd141. The Asahi compiler suite passed 1,955 with one skip, including both focused shared-store checks. Both AArch64 ICD builds and all 44 repository-policy self-tests passed.J615 (M3 Air, G15G C0) stayed on saved
7.3.0-aurora-edge. Confirmed the exact per-processVK_DRIVER_FILESand ran four alternating ABBA/BAAB pairs (32 fresh processes) withMESA_SHADER_CACHE_DISABLE=1 AGX_MESA_DEBUG=shaders. Each process dispatched 16,384 workgroups of 64 lanes, checked 1,048,576 reference outputs and the same number of sentinel words, and retained 20 GPU timestamp samples after four warmups. The candidate emits one shared store instead of two. The boot stayed unchanged and the kernel journal was empty.Median paired GPU time changed −0.01%, with blocks from −1.89% to +2.89%. Pooled medians were 141,500 ns and 143,020.5 ns (+1.07%). Both directions occurred in the paired comparison.
Vulkan fixture and timing
Risk
Moves two matching terminal shared stores into a single store after control-flow reconvergence. The pass admits equal address expressions, equal memory qualifiers and matching store properties, and refuses atomic and volatile stores.