naga
naga copied to clipboard
wgsl-in, glsl-in: Short circuit || and &&
Fixes gfx-rs/wgpu#4394.
Looking at this again, I think it is translating things correctly. The tests show that for the &&
case, the RHS is evaluated in the accept branch of the if statement, while for the ||
it is evaluated in the reject branch.
I'll have a go at generating multiple assignments instead of single assignment. Would it be better to create a logical not and always leave the reject branch empty so that the generated code doesn't use an else
in the ||
case?
Looking at this again, I think it is translating things correctly. The tests show that for the
&&
case, the RHS is evaluated in the accept branch of the if statement, while for the||
it is evaluated in the reject branch.
Tests seem correct indeed, but quite verbose (see below).
Would it be better to create a logical not and always leave the reject branch empty so that the generated code doesn't use an
else
in the||
case?
I think so (as per @JCapucho's suggestion) because the extra assignments are redundant, we already know the var is true/false.
Hello, thank you for your PR against Naga!
As part of https://github.com/gfx-rs/wgpu/issues/4231, we have moved development of Naga into the wgpu repository in the Naga subfolder. We have transferred all issues, but we are unable to automatically transfer PRs.
As such, please recreate your PR against the wgpu repository. We apologize for the inconvenience this causes, but will make contributing to both projects more streamlined going forward.
We are leaving PRs open, but once they are transferred, please close the original Naga PR.