Front-end: Implement compile-time constant folding for any() and all().

This commit is contained in:
John Kessenich
2016-07-12 01:26:43 -06:00
parent 91b7533d70
commit d8509b3367
3 changed files with 54 additions and 5 deletions

View File

@@ -374,6 +374,18 @@ ERROR: node is still EOpNull!
0:? 1 (const int)
0:? 9.000000
0:? false (const bool)
0:? 'cval1' (const bool)
0:? true (const bool)
0:? 'cval2' (const bool)
0:? false (const bool)
0:? 'cval3' (const bool)
0:? false (const bool)
0:? 'cval4' (const bool)
0:? true (const bool)
0:? 'cval5' (const bool)
0:? false (const bool)
0:? 'cval6' (const bool)
0:? true (const bool)
Linked fragment stage:
@@ -744,4 +756,16 @@ ERROR: node is still EOpNull!
0:? 1 (const int)
0:? 9.000000
0:? false (const bool)
0:? 'cval1' (const bool)
0:? true (const bool)
0:? 'cval2' (const bool)
0:? false (const bool)
0:? 'cval3' (const bool)
0:? false (const bool)
0:? 'cval4' (const bool)
0:? true (const bool)
0:? 'cval5' (const bool)
0:? false (const bool)
0:? 'cval6' (const bool)
0:? true (const bool)

View File

@@ -138,4 +138,11 @@ const cag a0[3] = cag[3](cag(3, 2.0, true), cag(1, 5.0, true), cag(1, 9.0, false
void foo4()
{
int a = int(a0[2].f);
}
}
const bool cval1 = all(bvec4(true, true, true, true));
const bool cval2 = all(bvec4(false, false, false, false));
const bool cval3 = all(bvec4(true, true, false, true));
const bool cval4 = any(bvec4(true, true, true, true));
const bool cval5 = any(bvec4(false, false, false, false));
const bool cval6 = any(bvec4(false, true, false, false));