skia2/tests/sksl/folding
John Stiles 14a487fd54 Replace getConstantSubexpression with getConstantValue.
The only type of expressions that getConstantSubexpression could ever
return are Literal and nullptr. getConstantValue now returns an
optional<double>; nullopt indicates a non-constant value in the slot.
This simplifies most use cases, and allows us to get rid of some extra
"zero" and "one" Literal objects in some of our Constructor classes.

This change fixes a recent fuzzer issue. The fuzzer had discovered that
calling `getConstantSubexpression` on a ConstructorCompoundCast that
contained a compile-time-constant value would return literals of the
wrong type (the cast was not applied). By nesting repeated matrix casts,
this type confusion could be turned into an assertion.

Change-Id: Icee69219e6db2822ffdfab4e5ccdaff54584a4b6
Bug: oss-fuzz:41000
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/471376
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-11-15 14:46:21 +00:00
..
ArrayFolding.glsl Improve index-folding of arrays and matrices. 2021-11-11 18:59:04 +00:00
ArraySizeFolding.glsl Implement constant folding for index expressions into matrices. 2021-11-10 21:38:56 +00:00
AssignmentOps.glsl Performance experiment: disable control-flow analysis. 2021-03-08 19:41:19 +00:00
BoolFolding.glsl Improve constant folding for boolean vectors. 2021-08-24 18:12:12 +00:00
CastFolding.glsl Fold casts of known values at compile time. 2021-05-07 22:04:48 +00:00
FloatFolding.glsl Remove 0/x arithmetic simplification. 2021-08-24 19:18:41 +00:00
IntFoldingES2.glsl Remove 0/x arithmetic simplification. 2021-08-24 19:18:41 +00:00
IntFoldingES3.glsl Revert "Inline functions of the form 'return (expr)' only." 2021-03-15 22:08:48 +00:00
MatrixFoldingES2.glsl Replace getConstantSubexpression with getConstantValue. 2021-11-15 14:46:21 +00:00
MatrixFoldingES3.glsl Revert "Inline functions of the form 'return (expr)' only." 2021-03-15 22:08:48 +00:00
SelfAssignment.glsl Performance experiment: disable control-flow analysis. 2021-03-08 19:41:19 +00:00
ShortCircuitBoolFolding.glsl Remove usage of sqrt() as an optimization barrier in tests. 2021-05-24 17:18:54 +00:00
SwizzleFolding.glsl Reland "Optimize away swizzles of constant variables." 2021-04-30 13:12:18 +00:00
VectorScalarFolding.glsl Remove 0/x arithmetic simplification. 2021-08-24 19:18:41 +00:00
VectorVectorFolding.glsl Remove 0/x arithmetic simplification. 2021-08-24 19:18:41 +00:00