<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/source/slang/slang-ir-dce.cpp, branch master</title>
<subtitle>Making it easier to work with shaders</subtitle>
<id>https://git.yummers.dev/slang.git/atom?h=master</id>
<link rel='self' href='https://git.yummers.dev/slang.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/'/>
<updated>2025-10-15T01:00:47+00:00</updated>
<entry>
<title>Clean up Slang IR representation of undefined values (#8708)</title>
<updated>2025-10-15T01:00:47+00:00</updated>
<author>
<name>Theresa Foley</name>
<email>10618364+tangent-vector@users.noreply.github.com</email>
</author>
<published>2025-10-15T01:00:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=907410f6a52cf4e7538870ebf5aeb88858f97973'/>
<id>urn:sha1:907410f6a52cf4e7538870ebf5aeb88858f97973</id>
<content type='text'>
Prior to this change, the Slang IR used a single opcode
(`kIROp_Undefined`) to encode all cases of undefined values. The
particular motivation for this change was a need to distinguish those
undefined values that represent a load from an uninitialized memory
location versus other sorts of undefined values. If transforming a
variable into SSA form results in `undefined` values in cases where the
a `load` was executed without a prior `store`, that represents an error
on the programmer's part, and should be diagnosed. However, other cases
of undefined values can arise during program transformation and
optimization, and should not typically result in diagnostics being
emitted.

While it was not the original motivation for this change, it is also
worth noting that the LLVM project has transitioned from initially using
only a single `undef` instruction to having a more nuanced model, and
the same factors that motivated their shift also apply to the Slang IR.
Counter-intuitively, the semantics of undefined values actually need to
be carefully defined.

Concretely, this change splits the pre-existing `undefined` opcode into
two sub-cases:

- `kIROp_LoadFromUninitializedMemory`, to represent the case of loading
from a memory location (such as a local variable) that has not been
initialized.

- `kIROp_Poison`, corresponding to the LLVM `poison` value.

Our poison instruction is intended to have semantics comparable to
LLVM's equivalent. Conceptually, any operation that is invoked with a
poison value as input will (with a few exceptions) produce a poison
value as output. One can think of the behavior of `poison` as similar to
how not-a-number values propagate in floating-point computations: by
default they "infect" the result of any computation they are involved
in. This semantic choice helps to ensure that many optimizations end up
being correct in the presence of undefined values, even if they did not
specifically account for them.

The `kIROp_LoadFromUninitializedMemory` case is comparable to the
combination of `freeze` and `undef` in LLVM. An LLVM `undef` value has
semantics that allow *each* use of that value to be replaced with a
*different* arbitrary value; these semantics cause many optimizations to
only be correct in the absence of undefined values. An LLVM `freeze`
instruction can take an undefined value as input, and produces a single
value that is still arbitrary, but must be consistent across all uses.
The latter semantics are what we want, since a given `load` from an
uninitialized memory location will yield an arbitrary-but-fixed value.

Note that we intentionally do not have a direct analogue to LLVM's
`undef` instruction, because of the way that `undef` causes so many
complications when trying to write optimizations.

We also do not add a `kIROp_Freeze` instruction in this change, but that
is simply because we currently have no need for it.

Existing code that was creating `IRUndefined` values has been updated to
create either `IRPoison` or `IRLoadFromUninitializedMemory` values, as
appropriate to the use case. Code that was checking for the
`kIROp_Undefined` opcode has been updated to either check for both of
the new opcodes (in the case of `switch` statements), or to use
`as&lt;IRUndefined&gt;` to perform a dynamic cast to the common base type of
the two new instructions.

Note that this change does not alter the way that instructions
representing undefined values are typically emitted as ordinary
instructions in the block that produces an undefined value. While
emitting `IRLoadFromUninitializedMemory` as an ordinary instruction is
exactly what we want, the `IRPoison` case would actually be better
represented in Slang IR as a "hoistable" instruction, so that there
would only be a singular `poison` value of each type. Changing
`IRPoison` to be hoistable would be a good follow-up change, but might
run into more challenges depending on what assumptions (if any) the
codebase is making about where undefined values get emitted.

---------

Co-authored-by: slangbot &lt;186143334+slangbot@users.noreply.github.com&gt;</content>
</entry>
<entry>
<title>Add Slang Byte Code generation and interpreter. (#6896)</title>
<updated>2025-04-28T18:42:22+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2025-04-28T18:42:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=c39c29bf4c52a85d7c83cc8b66ae45e265f9e078'/>
<id>urn:sha1:c39c29bf4c52a85d7c83cc8b66ae45e265f9e078</id>
<content type='text'>
* Add Slang Byte Code generation and interpreter.

* Fix compile issues.

* format code

* More compile fix.

* Fix clang issue.

* Fix more clang issues.

* Another clang fix.

* Fix clang issues.

* Fix another clang issue.

* Fix wasm build.

* Update building.md

* Fix test-server.

* Fix compile error.

* Fix bug.

---------

Co-authored-by: slangbot &lt;186143334+slangbot@users.noreply.github.com&gt;</content>
</entry>
<entry>
<title>Move switch statement bodies to their own lines (#5493)</title>
<updated>2024-11-05T17:47:26+00:00</updated>
<author>
<name>Ellie Hermaszewska</name>
<email>ellieh@nvidia.com</email>
</author>
<published>2024-11-05T17:47:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=b118451e301d734e3e783b3acdf871f3f6ea851c'/>
<id>urn:sha1:b118451e301d734e3e783b3acdf871f3f6ea851c</id>
<content type='text'>
* Move switch statement bodies to their own lines

* format

---------

Co-authored-by: Yong He &lt;yonghe@outlook.com&gt;</content>
</entry>
<entry>
<title>format</title>
<updated>2024-10-29T06:49:26+00:00</updated>
<author>
<name>Ellie Hermaszewska</name>
<email>ellieh@nvidia.com</email>
</author>
<published>2024-10-29T06:49:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21'/>
<id>urn:sha1:f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21</id>
<content type='text'>
* format

* Minor test fixes

* enable checking cpp format in ci</content>
</entry>
<entry>
<title>Assorted auto-diff enhancements for increased performance &amp; more streamlined auto-diff results (#5394)</title>
<updated>2024-10-28T19:47:58+00:00</updated>
<author>
<name>Sai Praveen Bangaru</name>
<email>31557731+saipraveenb25@users.noreply.github.com</email>
</author>
<published>2024-10-28T19:47:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=b61be5e6fb7fe1c4ec8228cdf73f49f11e5a0ac9'/>
<id>urn:sha1:b61be5e6fb7fe1c4ec8228cdf73f49f11e5a0ac9</id>
<content type='text'>
* Various AD enhancements

* Fix issue with pt-loop test

* Update pt-loop.slang

* More fixes for perf. Final minimal context test now passes.

* Fix issue with loop-elimination pass not running after dce

* Try fix wgpu test by removing select operator

* Disable wgpu

* Delete out.wgsl

* Remove comments

* Update slang-ir-util.cpp

* Fix header relative paths for slang-embed

* Disbale wgpu for a few other tests

* Better way of determining which params to ignore for side-effects

* Update slang-ir-dce.cpp

* Fix issue with circular reference from previous AD pass being left behind for the next AD pass

* Update slang-ir-dce.cpp</content>
</entry>
<entry>
<title>Add option to preserve shader parameter declaration in output SPIRV. (#4344)</title>
<updated>2024-06-12T16:27:14+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2024-06-12T16:27:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=fa8c11ebe8f9b1bf2174a5a4dbe92a34c16811c8'/>
<id>urn:sha1:fa8c11ebe8f9b1bf2174a5a4dbe92a34c16811c8</id>
<content type='text'>
* Add option to preserve shader parameter declarations in output.

* Add test.</content>
</entry>
<entry>
<title>Add options to speedup compilation. (#4240)</title>
<updated>2024-05-29T18:14:22+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2024-05-29T18:14:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=83f176ba8a3bae5533470aed6a90663653f894b8'/>
<id>urn:sha1:83f176ba8a3bae5533470aed6a90663653f894b8</id>
<content type='text'>
* Add options to speedup compilation.

* Fix.

* Plumb options to DCE pass.

* Revert debug change.

* Fix regressions.

* More optimizations.

* more cleanup and fixes.

* remove comment.

* Fixes.

* Another fix.

* Fix errors.

* Fix errors.

* Add comments.</content>
</entry>
<entry>
<title>Pool inst worklists and hashsets to avoid rehashing. (#2982)</title>
<updated>2023-07-13T02:55:41+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2023-07-13T02:55:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=f3aba255f6d69ddbf255b33d0eb0f391908e60a8'/>
<id>urn:sha1:f3aba255f6d69ddbf255b33d0eb0f391908e60a8</id>
<content type='text'>
Co-authored-by: Yong He &lt;yhe@nvidia.com&gt;</content>
</entry>
<entry>
<title>Use scratchData on `IRInst` to replace HashSets. (#2978)</title>
<updated>2023-07-12T23:00:05+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2023-07-12T23:00:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=261b2f1f2bc13ccf7db5ec68c825ffc7b0781f7f'/>
<id>urn:sha1:261b2f1f2bc13ccf7db5ec68c825ffc7b0781f7f</id>
<content type='text'>
* Use scratchData on `IRInst` to replace HashSets.

* Update test results.

* Initialize scratchData.

* Update autodiff documentation.

* Use enum instead of bool.

---------

Co-authored-by: Yong He &lt;yhe@nvidia.com&gt;</content>
</entry>
<entry>
<title>Fix DCE on mutable calls in a loop. (#2943)</title>
<updated>2023-06-26T22:18:06+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2023-06-26T22:18:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=4c9e4de4b68f2612a39e8783e9da89605ecf54e0'/>
<id>urn:sha1:4c9e4de4b68f2612a39e8783e9da89605ecf54e0</id>
<content type='text'>
* Fix DCE on mutable calls in a loop.

* More accurate in-loop test.

* code review  fixes.

* Fix.

---------

Co-authored-by: Yong He &lt;yhe@nvidia.com&gt;</content>
</entry>
</feed>
