-
Notifications
You must be signed in to change notification settings - Fork 72
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
ccb2e39
to
3dbaf18
Compare
…nlined function.
3dbaf18
to
e5b8b18
Compare
SpirvValue
, and especiallySpirvValueKind
, have been serving several purposes so far:struct SpirvValue { kind: SpirvValueKind, ty: ... }
before this PR)SpirvConst
s (already have some of that done for later PRs)SpirvValueKind::IllegalConst
, aSpan
isn't known initially at all(so there's a need to defer until the time of
SpirvValue::def
, which may bring aSpan
)SpirvValue::strip_ptrcasts
undo pointer castsSpirvValueKind::LogicalPtrCast
contains 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:
Span
at mostbool
field (zombie_waiting_for_span
) replacesSpirvValueKind::IllegalConst
SpirvValue::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::LogicalPtrCast
with an equivalentOption
inSpirvValueKind::Def
SpirvValue
generic and reusing it,SpirvValue::strip_ptrcasts
becomessimpler and combining it with
pointercast
is now lossless (wrt other details)SpirvValue
that is simultaneously like the oldSpirvValueKind::IllegalConst
andSpirvValueKind::LogicalPtrCast
at the same time(arguably the main motivation for this PR, specifically as a
const_bitcast
result)SpirvValue
s in theSpirvConst
<->SPIR-V ID "const interning" mapsSpirvValue
's new generic param),this removes all duplicated logic around "deriving
SpirvValue
for a constant"(i.e. what used to decide whether
SpirvValueKind::IllegalConst
should be used)SpirvValue::const_fold_load
becomes trivial, but even more important, lossless(returning the same exact
SpirvValue
as the originalSpirvConst
did)