8f440b4e1e
Expressions like `x * 1`, `x *= 1`, `x + 0`, `x * 0`, or `0 / x` don't actually do anything, and can be simplified to just `x` or `0`. (The zero case must also check that `x` doesn't have side effects, because `0 * myFunction()` still needs to call `myFunction`.) `0 - x` is also detected and rewritten as `-x`. `0 / 0` is left as-is. This logic works for scalars and vectors; matrices are left as-is. A similar optimization also occurs in the constant-propagation pass, so we see almost no diffs in the tests. If control-flow analysis is turned off, we do see some improvements. (I didn't reuse the existing code at all, since it was designed around rewriting the CFG tree, but the concept was identical.) Change-Id: Ia99cd81f1d4cd3dafaa43ccac6a2261e3257a185 Bug: skia:11343 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/380356 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com> |
||
---|---|---|
.. | ||
FirstClassArrays.skvm | ||
IllegalArrayOps.skvm | ||
IllegalIndexing.skvm | ||
IllegalOperators.skvm | ||
IllegalStatements.skvm | ||
LoopConditionErrors.skvm | ||
LoopExpressionErrors.skvm | ||
LoopInitializerErrors.skvm | ||
LoopStructureErrors.skvm | ||
UnsupportedTypeSampler.skvm | ||
UnsupportedTypeTexture.skvm |