-
Notifications
You must be signed in to change notification settings - Fork 78
Make SpirvValue(Kind) representation and operations more orthogonal and robust (lossless).
#348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
1e33b18 to
b4ed844
Compare
|
Tested on my nanite-at-home project, 3 runs, first run after branch switch discarded (due to many CPU crates recompiling), cmdline: older master 8ee9f2f: 16.3s 16.4s 16.6s This branch is slightly faster 🎉 |
Pull request was converted to draft
Wow, that's in the opposite direction from what I heard from @nazar-pc, but it's good to know it can swing either way. In the meanwhile, I really want to land certain soundness fixes in So I've marked this PR as draft, and I hope to come up with something isolated, and we can land this later. EDIT: the soundness fix PR is now up: |
b4ed844 to
e0ca2a2
Compare
71292fd to
ccb2e39
Compare
3dbaf18 to
e5b8b18
Compare
e5b8b18 to
cd3ee54
Compare
…] [2024] WIP: mem2reg unsound changes??
…nlined function.
cd3ee54 to
8395cee
Compare
SpirvValue, and especiallySpirvValueKind, have been serving several purposes so far:struct SpirvValue { kind: SpirvValueKind, ty: ... }before this PR)SpirvConsts (already have some of that done for later PRs)SpirvValueKind::IllegalConst, aSpanisn't known initially at all(so there's a need to defer until the time of
SpirvValue::def, which may bring aSpan)SpirvValue::strip_ptrcastsundo pointer castsSpirvValueKind::LogicalPtrCastcontains the value and type IDs for aSpirvValue(
SpirvValue { kind: SpirvValueKind::Def(original_ptr), ty: original_ptr_ty })That has grown ad-hoc, and it can be a nightmare to extend any part of it, hence this work.
More specifically, this PR:
Spanat mostboolfield (zombie_waiting_for_span) replacesSpirvValueKind::IllegalConstSpirvValue::def(which is called everywhere to obtain a SPIR-V ID)only has to check a
bool(for registering theSpan), no more string formattingto generate the string message themselves, but it's unclear if that was ever skipped
(and I wasn't able to observe any change in build times, tho more testing is welcome)
SpirvValueKind::LogicalPtrCastwith an equivalentOptioninSpirvValueKind::DefSpirvValuegeneric and reusing it,SpirvValue::strip_ptrcastsbecomessimpler and combining it with
pointercastis now lossless (wrt other details)SpirvValuethat is simultaneously like the oldSpirvValueKind::IllegalConstandSpirvValueKind::LogicalPtrCastat the same time(arguably the main motivation for this PR, specifically as a
const_bitcastresult)SpirvValues in theSpirvConst<->SPIR-V ID "const interning" mapsSpirvValue's new generic param),this removes all duplicated logic around "deriving
SpirvValuefor a constant"(i.e. what used to decide whether
SpirvValueKind::IllegalConstshould be used)SpirvValue::const_fold_loadbecomes trivial, but even more important, lossless(returning the same exact
SpirvValueas the originalSpirvConstdid)