skia2/tests/sksl/workarounds
John Stiles 77702f1704 Eliminate inliner temporary variables for top-level-exit functions.
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>
2020-12-17 20:37:21 +00:00
..
golden Eliminate inliner temporary variables for top-level-exit functions. 2020-12-17 20:37:21 +00:00
AbsInt.sksl Migrate several GLSL workaround unit tests to golden files. 2020-09-17 16:41:18 +00:00
BlendGuardedDivide.sksl Add test for sk_Caps.mustGuardDivisionEvenAfterExplicitZeroCheck. 2020-10-09 13:48:13 +00:00
BlendModesAllZeroVec.sksl Add test for sk_Caps.inBlendModesFailRandomlyForAllZeroVec. 2020-10-09 13:44:43 +00:00
FractNegative.sksl Migrate several GLSL workaround unit tests to golden files. 2020-09-17 16:41:18 +00:00
FragCoords.sksl Migrate remaining SkSL GLSL tests to golden outputs. 2020-09-18 19:22:19 +00:00
LoopCondition.sksl Migrate several GLSL workaround unit tests to golden files. 2020-09-17 16:41:18 +00:00
MinAndAbsTogether.sksl Migrate several GLSL workaround unit tests to golden files. 2020-09-17 16:41:18 +00:00
NegatedAtan.sksl Migrate several GLSL workaround unit tests to golden files. 2020-09-17 16:41:18 +00:00
PowWithConstantExponent.sksl Migrate several GLSL workaround unit tests to golden files. 2020-09-17 16:41:18 +00:00
RewriteDoWhileLoops.sksl Migrate remaining SkSL GLSL tests to golden outputs. 2020-09-18 19:22:19 +00:00
TernaryShortCircuit.sksl Migrate several GLSL workaround unit tests to golden files. 2020-09-17 16:41:18 +00:00