edac7716aa
In particular, this optimizes abs() and sign() when all inputs are known at compile time. This resolves a TODO on a test case in `IllegalIndexing.rts`. Change-Id: Ica310522a85b42dc7ae255bd25004a6629d04176 Bug: skia:10835 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/405676 Auto-Submit: John Stiles <johnstiles@google.com> Commit-Queue: John Stiles <johnstiles@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
30 lines
1.1 KiB
Plaintext
30 lines
1.1 KiB
Plaintext
// Expect 3 errors
|
|
|
|
// Legal cases that should not produce errors:
|
|
void literal_index() { int a[2]; a[0] = 0; a[1] = a[0]; }
|
|
void const_var_index() { int a[2]; const int b = 0; a[b] = 0; }
|
|
void loop_index() { int a[2]; for (int i = 0; i < 2; ++i) { a[i] = i; } }
|
|
void loop_expr_binary() { int a[2]; for (int i = 0; i < 2; ++i) { a[1 - i] = i; } }
|
|
void loop_expr_unary() { int a[2]; for (int i = 0; i > -2; --i) { a[-i] = i; } }
|
|
void loop_swizzle() { int a[2]; for (int i = 0; i < 2; ++i) { a[i.x] = i; } }
|
|
void loop_ternary() { int a[2]; for (int i = 0; i < 2; ++i) { a[i > 0 ? i : 0] = i; } }
|
|
|
|
void loop_type_coerce() { float a[2]; for (float i = 0; i < 2; ++i) { a[int(i)] = i; } }
|
|
|
|
void loop_nested() {
|
|
int a[3];
|
|
for (int i = 0; i < 2; ++i)
|
|
for (int j = 0; j < 2; ++j) {
|
|
a[i + j] = j;
|
|
}
|
|
}
|
|
|
|
uniform int u;
|
|
|
|
// Illegal cases that should produce errors:
|
|
void uniform_index() { int a[2]; a[u] = 0; }
|
|
void param_index(int p) { int a[2]; a[p] = 0; }
|
|
|
|
// Legal in SkSL when optimization is enabled:
|
|
void func_index() { int a[2]; a[int(abs(-1))] = 0; }
|