Respect the result type during constant folding.
Previously, expressions like `(1.0 + myConstHalfVar)` would create a
FloatLiteral node of type `$floatLiteral`, instead of `half`. This could
cause an assertion if the IRNode containing that FloatLiteral value was
strict about types.
Example assertion: http://screen/5x9XXhxygRgk9rz
Change-Id: I42bf8285790d7939f07a6597e222bb6ac96d709b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402781
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/SkSLConstantFolder.cpp b/src/sksl/SkSLConstantFolder.cpp
index 862a0bc..6573d3f 100644
--- a/src/sksl/SkSLConstantFolder.cpp
+++ b/src/sksl/SkSLConstantFolder.cpp
@@ -409,9 +409,9 @@
// precision to calculate the results and hope the result makes sense.
// TODO(skia:10932): detect and handle integer overflow properly.
using SKSL_UINT = uint64_t;
- #define RESULT(t, op) t ## Literal::Make(context, offset, leftVal op rightVal)
- #define URESULT(t, op) t ## Literal::Make(context, offset, (SKSL_UINT) leftVal op \
- (SKSL_UINT) rightVal)
+ #define RESULT(t, op) t ## Literal::Make(offset, leftVal op rightVal, &resultType)
+ #define URESULT(t, op) t ## Literal::Make(offset, (SKSL_UINT)(leftVal) op \
+ (SKSL_UINT)(rightVal), &resultType)
if (left->is<IntLiteral>() && right->is<IntLiteral>()) {
SKSL_INT leftVal = left->as<IntLiteral>().value();
SKSL_INT rightVal = right->as<IntLiteral>().value();