blob: 7feb107a1bdda47e881dd8e783d7c1a0af5c6811 [file] [log] [blame]
uniform half4 colorRed, colorGreen;
int globalValue = 0;
noinline int side_effecting(int value) {
globalValue++;
return value;
}
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);
const int z = x[0] - y[0];
const int a [x[z]] = int[1](1);
const int b [x[x[z]]] = int[2](1, 2);
const int c [x[x[x[z]]]] = int[3](1, 2, 3);
// Arrays with elements lacking side-effects can be optimized.
int two = 2;
int flatten0 = (int[3](x[0], two, 3))[0];
int flatten1 = (int[3](x[0], two, 3))[1];
int flatten2 = (int[3](x[0], two, 3))[2];
// Arrays with elements that have side-effects are not eligible for optimization.
int noFlatten0 = (int[3](--two, side_effecting(2), 3))[0];
int noFlatten1 = (int[3](side_effecting(1), 2, 3))[1];
int noFlatten2 = (int[3](1, ++two, 3))[2];
return (x == xx) && !(x != xx) && (x != y) && !(x == y) &&
(x[0] == y[0]) && (c == x) &&
(flatten0 == noFlatten0) && (flatten1 == noFlatten1) && (flatten2 == noFlatten2);
}
half4 main(float2 coords) {
return test() ? colorGreen : colorRed;
}