77702f1704
When we determine that a function only contains a single return statement and it is at the top level (i.e. not inside any scopes), there is no need to create a temporary variable and store the result expression into a variable. Instead, we can directly replace the function-call expression with the return-statement's expression. Unlike my previous solution, this does not require variable declarations to be rewritten. The no-scopes limitation makes it slightly less effective in theory, but in practice we still get almost all of the benefit. The no-scope limitation bites us on structures like @if (true) { return x; } else { return y; } Which will optimize away the if, but leave the scope: { return x; } However, this is not a big deal; the biggest wins are single-line helper functions like `guarded_divide` and `unpremul` which retain the full benefit. Change-Id: I7fbb725e65db021b9795c04c816819669815578f Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345167 Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com> |
||
---|---|---|
.. | ||
AbsInt.glsl | ||
AbsIntStandaloneSettings.glsl | ||
BlendGuardedDivide.glsl | ||
BlendGuardedDivideStandaloneSettings.glsl | ||
BlendModesAllZeroVec.glsl | ||
BlendModesAllZeroVecStandaloneSettings.glsl | ||
FractNegative.glsl | ||
FractNegativeStandaloneSettings.glsl | ||
FragCoords.glsl | ||
FragCoordsStandaloneSettings.glsl | ||
LoopCondition.glsl | ||
LoopConditionStandaloneSettings.glsl | ||
MinAndAbsTogether.glsl | ||
MinAndAbsTogetherStandaloneSettings.glsl | ||
NegatedAtan.glsl | ||
NegatedAtanStandaloneSettings.glsl | ||
PowWithConstantExponent.glsl | ||
PowWithConstantExponentStandaloneSettings.glsl | ||
RewriteDoWhileLoops.glsl | ||
RewriteDoWhileLoopsStandaloneSettings.glsl | ||
TernaryShortCircuit.glsl | ||
TernaryShortCircuitStandaloneSettings.glsl |