skia2/tests/sksl/shared/NegatedVectorLiteral.sksl
John Stiles 71624de2c5 Allow constant propagation for negated constant-vectors and ints.
This CL improves on the previous fix for oss-fuzz:26789 by actually
propagating the negation from the PrefixExpression inside the
constructor, which unblocks further optimizations.

Interestingly, this fix also exposes a further missing optimization--we
optimize away comparisons of constant-vectors for floats, but fail to
do the same for ints.

Change-Id: I9d4cb92b10452a74db96ff264322cdc8a8f2a41f
Bug: oss-fuzz:26830, oss-fuzz:26789, skia:10908
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332263
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-11-05 17:39:48 +00:00

25 lines
717 B
Plaintext

void test_half() {
half one = 1;
half two = 2;
sk_FragColor.r = (half4(-1) == -half4(-half2(-1), half2(1))) ? 1 : 0;
sk_FragColor.g = (half4(1) != -half4(1)) ? 1 : 0;
sk_FragColor.b = (-half4(two) == half4(-two, half3(-two))) ? 1 : 0;
sk_FragColor.a = (-half2(-one, one + one) == -half2(one - two, two)) ? 1 : 0;
}
void test_int() {
int one = 1;
int two = 2;
sk_FragColor.r = (int4(-1) == -int4(-int2(-1), int2(1))) ? 1 : 0;
sk_FragColor.g = (int4(1) != -int4(1)) ? 1 : 0;
sk_FragColor.b = (-int4(two) == int4(-two, int3(-two))) ? 1 : 0;
sk_FragColor.a = (-int2(-one, one + one) == -int2(one - two, two)) ? 1 : 0;
}
void main() {
test_half();
test_int();
}