Add test for folding of == and != for arrays.

We don't directly support this today at all. In practice, though, simple
constant arrays are detected as equal in the constant-folding pass
because they hit the `x == x` self-equality check (using
`IsSameExpressionTree`).

This does not work for our inequality tests, though, so those do not
fold.

Change-Id: I6730a9a2d1da9ac613ee58889d651f3ff65b1d2d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/391057
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
John Stiles 2021-03-31 10:38:45 -04:00
parent 6e7d2b3b72
commit 8037c9e2ed
3 changed files with 24 additions and 0 deletions

View File

@ -444,6 +444,7 @@ sksl_shared_tests = [
]
sksl_folding_tests = [
"/sksl/folding/ArrayFolding.sksl",
"/sksl/folding/AssignmentOps.sksl",
"/sksl/folding/BoolFolding.sksl",
"/sksl/folding/FloatFolding.sksl",

View File

@ -0,0 +1,14 @@
uniform half4 colorRed, colorGreen;
bool test() {
const int x [3] = int[3](1, 2, 3);
const int xx[3] = int[3](1, 2, 3);
const int y [3] = int[3](1, 2, 4);
return (x == xx) && !(x != xx) && (x != y) && !(x == y);
}
half4 main() {
return test() ? colorGreen : colorRed;
}

View File

@ -0,0 +1,9 @@
out vec4 sk_FragColor;
uniform vec4 colorRed;
uniform vec4 colorGreen;
vec4 main() {
const int _0_x[3] = int[3](1, 2, 3);
const int _2_y[3] = int[3](1, 2, 4);
return _0_x != _2_y && !(_0_x == _2_y) ? colorGreen : colorRed;
}