<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/tests/compute/logic-short-circuit-evaluation.slang, 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-02-08T02:27:23+00:00</updated>
<entry>
<title>Use and() and or() functions for logical-AND and OR (#6310)</title>
<updated>2025-02-08T02:27:23+00:00</updated>
<author>
<name>Jay Kwak</name>
<email>82421531+jkwak-work@users.noreply.github.com</email>
</author>
<published>2025-02-08T02:27:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=57b09a8986668626c37055e431fa0ac6449d7214'/>
<id>urn:sha1:57b09a8986668626c37055e431fa0ac6449d7214</id>
<content type='text'>
* Use and() and or() functions for logical-AND and OR

With this commit, Slang will emit function calls to `and()` and `or()`
for the logical-AND and logical-OR when the operands are non-scalar and
the target profile is SM6.0 and above. This is required change from
SM6.0.

For WGSL, there is no operator overloadings of `&amp;&amp;` and `||` when the
operands are non-scalar. Unlike HLSL, WGSL also don't have `and()` nor
`or()`. Alternatively, we can use `select()`.</content>
</entry>
<entry>
<title>enable more metal tests (#4326)</title>
<updated>2024-06-10T20:28:36+00:00</updated>
<author>
<name>skallweitNV</name>
<email>64953474+skallweitNV@users.noreply.github.com</email>
</author>
<published>2024-06-10T20:28:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=712ce653d4c3d7284dd71389f31540d0da7f144e'/>
<id>urn:sha1:712ce653d4c3d7284dd71389f31540d0da7f144e</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Metal compute tests (#4292)</title>
<updated>2024-06-07T07:28:16+00:00</updated>
<author>
<name>skallweitNV</name>
<email>64953474+skallweitNV@users.noreply.github.com</email>
</author>
<published>2024-06-07T07:28:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=004fe27a52b7952111ad7e749397aeff499de7ed'/>
<id>urn:sha1:004fe27a52b7952111ad7e749397aeff499de7ed</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Implement short-circuit logic operator (#3635)</title>
<updated>2024-03-05T04:55:50+00:00</updated>
<author>
<name>kaizhangNV</name>
<email>149626564+kaizhangNV@users.noreply.github.com</email>
</author>
<published>2024-03-05T04:55:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=2297623aad4c249bccae3fe363ada31e308131ac'/>
<id>urn:sha1:2297623aad4c249bccae3fe363ada31e308131ac</id>
<content type='text'>
* Implement short-circuit logic operator

Implement short-circuit evaluation for logic &amp;&amp; and ||
operator.

The short-circuit behavior is only used when the operands
involved are scalar and the parent function is non-differentiable.

In implementation, we define a new class 'LogicOperatorShortCircuitExpr'
derived from 'OperatorExpr'. In the visitInvoke() call, we will create
a new expression object 'LogicOperatorShortCircuitExpr' if the
expression is logic &amp;&amp; or ||. So that we can generate new IR code in the
new visit function 'visitLogicOperatorShortCircuitExpr' to implement the
short-circuit behavior.

Add new test to test the short-circuit behavior.

* Fix an compile issue occurred in Falcon test

Previously, we early return when at least one of the operands of
"&amp;&amp;" or "||" is vector in convertToLogicOperatorExpr call. However,
in that case the arguments involved in the expression have already been
type checked. When it falls-back to 'visitInvokeExpr', it will check
the arguments again, and some unexpected behavior could occur
which could in turn cause some internal error.

So we add a check in the 'visitInvokeExpr' to avoid double type checking
of arguments.

* Update glsl subgroup test to not use short-circuit

Since the short-circuit evaluation could cause the threads
diverging in subgroup intrinsics. So change the test to not
using "&amp;&amp;" to chain those subgroup intrinsics together. Instead,
using "&amp;" to chain them together because those test functions have
the return value as bool.

* Disable short-circuit in few situations

Disable short-circuit in following situations:
1. generic parameter list
2. static const varible initialization

* Use a flag to indicate the enablement of short-circuit

Instead of using a struct to indicate the state of the outer
environment of current expression, use a simple bool flag to
indicate whether or not apply the short-circuit to current
expression because there few situations where we will disable
short-circuiting and in those circumstances, there is no nested.

Therefore, a flag is good enough to indicate the case.

* Disable short-circuit in index expression

Also fix the build issue. (A cleanup for the last change.)

* check both 'static' and 'const' modifiers

Previously we only check HLSLStaticModifier to decide whether or
not using short-circuit, but we really should check both 'static'
and 'const' modifiers together, because we only want to disable
the short circuit for init expression for 'static const' variable.

* relax the restriction of short-circuit for index expression

Disable the short-circuit for index expression only when declare
an array.

* Simplify the logic by creating subVisitor

Simplify the logic by create a sub expression visitor so
that we don't need to introduce extra recursion.

* Call convertToLogicOperatorExpr after args check

Change to call convertToLogicOperatorExpr after arguments
check in visitInvokeExpr such that we don't have to check
whether the arguments checked to avoid the double checking
issue.</content>
</entry>
</feed>
