Optimize away simple ternary expressions.
We now detect and simplify these forms:
- `test ? expr : false` can be simplified to `test && expr`.
- `test ? true : expr` can be simplified to `test || expr`.
- `test ? false : true` can be simplified to `!test`.
Note that the first case naturally covers `test ? true : false`, as
SkSL can already simplify `test && true` into `test`.
Unfortunately this breaks one test in WGSL, so I've rewritten the
test to use 0/1 instead of true/false.
Bug: skia:14133
Change-Id: Ifcd654531833498d0b9958154c3c650dca767520
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/649527
Commit-Queue: Arman Uguray <armansito@google.com>
Reviewed-by: Arman Uguray <armansito@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
16 files changed