8397365524
A ternary of the form `anything ? value : value` can be reduced to a comma-expression of the form `anything, value`. This seems like a rare case in real code, but it's easy enough to detect with our existing toolbox. The `anything` test-expression will be eliminated from the expression if it has no side effects, using our existing constant-folding rules for the comma expression. Change-Id: I1285b04cd6a08f1bed614aa1aa6f37ea2447de91 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/528439 Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: John Stiles <johnstiles@google.com>
18 lines
363 B
GLSL
18 lines
363 B
GLSL
|
|
out vec4 sk_FragColor;
|
|
uniform vec4 colorRed;
|
|
uniform vec4 colorGreen;
|
|
bool do_side_effect_bb(out bool x) {
|
|
x = true;
|
|
return false;
|
|
}
|
|
vec4 main() {
|
|
bool ok;
|
|
ok = true;
|
|
vec4 green = colorGreen;
|
|
vec4 red = colorRed;
|
|
bool param = false;
|
|
bool call = (do_side_effect_bb(param), true);
|
|
return (ok && param) && call ? green : red;
|
|
}
|