dawn-cmake/test/bug/tint/221.wgsl.expected.hlsl
Ben Clayton ed86bf99b0 Add transform::Simplify
Performs basic peephole optimizations on the AST.

Use in transform::Hlsl.

Required to have the DecomposeStorageAccess transform operate correctly with the output of InlinePointerLets transform, specifically when declaring `let` pointer expressions to storage buffers.

Fixed: tint:221
Fixed: tint:492
Fixed: tint:829
Change-Id: I536390921a6492378104e9c3c100d9e761294a27
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51921
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2021-05-21 21:01:23 +00:00

28 lines
539 B
HLSL

ByteAddressBuffer b : register(t0, space0);
[numthreads(1, 1, 1)]
void main() {
uint i = 0u;
while (true) {
if ((i >= b.Load(0u))) {
break;
}
const uint p_save = i;
if (((i % 2u) == 0u)) {
{
b.Store((4u + (4u * p_save)), asuint((b.Load((4u + (4u * p_save))) * 2u)));
i = (i + 1u);
}
continue;
}
b.Store((4u + (4u * p_save)), asuint(0u));
{
b.Store((4u + (4u * p_save)), asuint((b.Load((4u + (4u * p_save))) * 2u)));
i = (i + 1u);
}
}
return;
}