diff options
| author | Yong He <yonghe@outlook.com> | 2023-03-23 16:59:02 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-23 16:59:02 -0700 |
| commit | 50e7d9797d9bf4b98a056d5df128c24dde6e78bd (patch) | |
| tree | 3e6e4491b1b6512280adff1d69a93ccaf50f6bb3 /tests/experimental/liveness | |
| parent | 85f005888cadeb4b1d957b57a86cbad6cc9ea313 (diff) | |
Fix optimization pass not converging. (#2725)
* Fix optimization pass not converging.
* Fix.
* Fix tests.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests/experimental/liveness')
5 files changed, 62 insertions, 71 deletions
diff --git a/tests/experimental/liveness/liveness-3.slang.expected b/tests/experimental/liveness/liveness-3.slang.expected index d4b417082..7719c6bb1 100644 --- a/tests/experimental/liveness/liveness-3.slang.expected +++ b/tests/experimental/liveness/liveness-3.slang.expected @@ -55,15 +55,14 @@ int calcThing_0(int offset_0) idx_0[0] = 0; idx_0[1] = 0; idx_0[2] = 0; - int _S2 = (k_0 + 7) % 5; - bool _S3 = _S2 == 4; + bool _S2 = (k_0 + 7) % 5 == 4; int k_1 = k_0 + 1; int i_0; livenessStart_1(i_0, 0); i_0 = 0; - int _S4; - livenessStart_1(_S4, 0); - _S4 = _S1; + int _S3; + livenessStart_1(_S3, 0); + _S3 = _S1; for(;;) { if(i_0 < 17) @@ -76,71 +75,69 @@ int calcThing_0(int offset_0) } int modRange_0 = i_0 % 3; another_0[i_0 & 1] = another_0[i_0 & 1] + modRange_0; - int _S5 = i_0 % 3; - int _S6; + int _S4; if(modRange_0 != 0) { - int _S7 = _S4; - livenessEnd_0(_S4, 0); - int _S8 = _S7 + 1; - livenessStart_1(_S6, 0); - _S6 = _S8; + int _S5 = _S3; + livenessEnd_0(_S3, 0); + int _S6 = _S5 + 1; + livenessStart_1(_S4, 0); + _S4 = _S6; } else { - int _S9 = _S4; - livenessEnd_0(_S4, 0); - livenessStart_1(_S6, 0); - _S6 = _S9; + int _S7 = _S3; + livenessEnd_0(_S3, 0); + livenessStart_1(_S4, 0); + _S4 = _S7; } - idx_0[modRange_0] = idx_0[modRange_0] + (_S6 + i_0); + idx_0[modRange_0] = idx_0[modRange_0] + (_S4 + i_0); i_0 = i_0 + 1; - livenessStart_1(_S4, 0); - int _S10 = _S6; - livenessEnd_0(_S6, 0); - _S4 = _S10; + livenessStart_1(_S3, 0); + int _S8 = _S4; + livenessEnd_0(_S4, 0); + _S3 = _S8; } livenessEnd_0(_S1, 0); livenessEnd_0(k_0, 0); - if(_S3) + if(_S2) { - livenessEnd_0(_S4, 0); + livenessEnd_0(_S3, 0); livenessEnd_1(idx_0, 0); livenessEnd_2(another_0, 0); return total_0; } - int _S11 = idx_0[0] + idx_0[1]; - int _S12 = idx_0[2]; + int _S9 = idx_0[0] + idx_0[1]; + int _S10 = idx_0[2]; livenessEnd_1(idx_0, 0); - int _S13 = _S11 + _S12; - int _S14 = total_0; + int _S11 = _S9 + _S10; + int _S12 = total_0; livenessEnd_0(total_0, 0); - int total_1 = _S14 + _S13; + int total_1 = _S12 + _S11; livenessStart_1(k_0, 0); k_0 = k_1; livenessStart_1(_S1, 0); - int _S15 = _S4; - livenessEnd_0(_S4, 0); - _S1 = _S15; + int _S13 = _S3; + livenessEnd_0(_S3, 0); + _S1 = _S13; livenessStart_1(total_0, 0); total_0 = total_1; } livenessEnd_2(another_0, 0); - int _S16 = total_0; + int _S14 = total_0; livenessEnd_0(total_0, 0); - return - _S16; + return - _S14; } -layout(std430, binding = 0) buffer _S17 { +layout(std430, binding = 0) buffer _S15 { int _data[]; } outputBuffer_0; layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; void main() { int index_0 = int(gl_GlobalInvocationID.x); - uint _S18 = uint(index_0); - int _S19 = calcThing_0(index_0); - ((outputBuffer_0)._data[(_S18)]) = _S19; + int _S16 = calcThing_0(index_0); + ((outputBuffer_0)._data[(uint(index_0))]) = _S16; return; } diff --git a/tests/experimental/liveness/liveness-4.slang.expected b/tests/experimental/liveness/liveness-4.slang.expected index 483247ecd..d6662c6a3 100644 --- a/tests/experimental/liveness/liveness-4.slang.expected +++ b/tests/experimental/liveness/liveness-4.slang.expected @@ -37,8 +37,7 @@ int calcThing_0(int offset_0) livenessEnd_0(k_0, 0); break; } - int _S1 = (k_0 + 7) % 5; - bool _S2 = _S1 == 4; + bool _S1 = (k_0 + 7) % 5 == 4; int k_1 = k_0 + 1; int i_0; livenessStart_1(i_0, 0); @@ -57,7 +56,7 @@ int calcThing_0(int offset_0) i_0 = i_0 + 1; } livenessEnd_0(k_0, 0); - if(_S2) + if(_S1) { livenessEnd_1(another_0, 0); return 1; @@ -69,16 +68,15 @@ int calcThing_0(int offset_0) return -2; } -layout(std430, binding = 0) buffer _S3 { +layout(std430, binding = 0) buffer _S2 { int _data[]; } outputBuffer_0; layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; void main() { int index_0 = int(gl_GlobalInvocationID.x); - uint _S4 = uint(index_0); - int _S5 = calcThing_0(index_0); - ((outputBuffer_0)._data[(_S4)]) = _S5; + int _S3 = calcThing_0(index_0); + ((outputBuffer_0)._data[(uint(index_0))]) = _S3; return; } diff --git a/tests/experimental/liveness/liveness-5.slang.expected b/tests/experimental/liveness/liveness-5.slang.expected index 5e144a095..c2ce1d741 100644 --- a/tests/experimental/liveness/liveness-5.slang.expected +++ b/tests/experimental/liveness/liveness-5.slang.expected @@ -40,8 +40,7 @@ int calcThing_0(int offset_0) livenessEnd_0(k_0, 0); break; } - int _S1 = (k_0 + 7) % 5; - bool _S2 = _S1 == 4; + bool _S1 = (k_0 + 7) % 5 == 4; int k_1 = k_0 + 1; int i_0; livenessStart_1(i_0, 0); @@ -60,10 +59,10 @@ int calcThing_0(int offset_0) i_0 = i_0 + 1; } livenessEnd_0(k_0, 0); - int _S3 = total_0; + int _S2 = total_0; livenessEnd_0(total_0, 0); - int total_1 = _S3 + another_0[k_0 & 1]; - if(_S2) + int total_1 = _S2 + another_0[k_0 & 1]; + if(_S1) { livenessEnd_1(another_0, 0); return 1; @@ -84,16 +83,15 @@ int calcThing_0(int offset_0) return total_0; } -layout(std430, binding = 0) buffer _S4 { +layout(std430, binding = 0) buffer _S3 { int _data[]; } outputBuffer_0; layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; void main() { int index_0 = int(gl_GlobalInvocationID.x); - uint _S5 = uint(index_0); - int _S6 = calcThing_0(index_0); - ((outputBuffer_0)._data[(_S5)]) = _S6; + int _S4 = calcThing_0(index_0); + ((outputBuffer_0)._data[(uint(index_0))]) = _S4; return; } diff --git a/tests/experimental/liveness/liveness-6.slang.expected b/tests/experimental/liveness/liveness-6.slang.expected index 0d2e997b2..45e94a242 100644 --- a/tests/experimental/liveness/liveness-6.slang.expected +++ b/tests/experimental/liveness/liveness-6.slang.expected @@ -45,8 +45,7 @@ int calcThing_0(int offset_0) arr_0[0] = 2; arr_0[1] = 3; int _S1 = k_0 & 1; - int _S2 = (k_0 + 7) % 5; - bool _S3 = _S2 == 4; + bool _S2 = (k_0 + 7) % 5 == 4; int k_1 = k_0 + 1; int i_0; livenessStart_1(i_0, 0); @@ -66,13 +65,13 @@ int calcThing_0(int offset_0) i_0 = i_0 + 1; } livenessEnd_0(k_0, 0); - int _S4 = total_0; + int _S3 = total_0; livenessEnd_0(total_0, 0); - int total_1 = _S4 + another_0[_S1]; - int _S5 = arr_0[_S1]; + int total_1 = _S3 + another_0[_S1]; + int _S4 = arr_0[_S1]; livenessEnd_1(arr_0, 0); - int total_2 = total_1 + _S5; - if(_S3) + int total_2 = total_1 + _S4; + if(_S2) { livenessEnd_1(another_0, 0); return 1; @@ -93,16 +92,15 @@ int calcThing_0(int offset_0) return total_0; } -layout(std430, binding = 0) buffer _S6 { +layout(std430, binding = 0) buffer _S5 { int _data[]; } outputBuffer_0; layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; void main() { int index_0 = int(gl_GlobalInvocationID.x); - uint _S7 = uint(index_0); - int _S8 = calcThing_0(index_0); - ((outputBuffer_0)._data[(_S7)]) = _S8; + int _S6 = calcThing_0(index_0); + ((outputBuffer_0)._data[(uint(index_0))]) = _S6; return; } diff --git a/tests/experimental/liveness/liveness.slang.expected b/tests/experimental/liveness/liveness.slang.expected index b0017ea9d..46b8f0922 100644 --- a/tests/experimental/liveness/liveness.slang.expected +++ b/tests/experimental/liveness/liveness.slang.expected @@ -92,9 +92,9 @@ layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; void main() { int index_0 = int(gl_GlobalInvocationID.x); - const int _S10[100] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - int _S11 = index_0 & 7; - SomeStruct_0 _S12 = makeSomeStruct_0(); + SomeStruct_0 _S10 = makeSomeStruct_0(); + const int _S11[100] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + int _S12 = index_0 & 7; int v_1 = someSlowFunc_0(index_0); bool _S13 = (v_1 & 256) != 0; int _S14 = v_1 & 3; @@ -118,7 +118,7 @@ void main() livenessStart_2(s_3, 0); SomeStruct_0 t_0; livenessStart_2(t_0, 0); - t_0 = _S12; + t_0 = _S10; SomeStruct_0 u_0; if(_S13) { @@ -127,7 +127,7 @@ void main() livenessStart_2(u_0, 0); u_0.a_1 = 0; u_0.x_0 = 0; - u_0.c_0 = _S10; + u_0.c_0 = _S11; } else { @@ -135,14 +135,14 @@ void main() livenessStart_2(x_1, 0); x_1.a_1 = 0; x_1.x_0 = 0; - x_1.c_0 = _S10; + x_1.c_0 = _S11; x_1.x_0 = ((anotherBuffer_0)._data[(uint(_S14))]) + 1; SomeStruct_0 _S15 = x_1; livenessEnd_2(x_1, 0); livenessStart_2(u_0, 0); u_0 = _S15; } - s_3.c_0[_S11] = s_3.c_0[_S11] + 1; + s_3.c_0[_S12] = s_3.c_0[_S12] + 1; int _S16 = s_3.x_0 + t_0.x_0; SomeStruct_0 _S17 = u_0; livenessEnd_2(u_0, 0); |
