integer type operation should not be noContraction

This commit is contained in:
qining 2016-05-06 21:52:28 -04:00
parent 34d257184a
commit 5bec2b5619
5 changed files with 116 additions and 124 deletions

View File

@ -55,46 +55,45 @@ vertices = -1
0:16 Constant:
0:16 5.000000
0:17 Sequence
0:17 move second child to first child (temp int)
0:17 'a' (noContraction temp int)
0:17 move second child to first child (temp float)
0:17 'a' (noContraction temp float)
0:17 Constant:
0:17 10 (const int)
0:17 10.000000
0:18 Sequence
0:18 move second child to first child (temp int)
0:18 'b' (noContraction temp int)
0:18 move second child to first child (temp float)
0:18 'b' (noContraction temp float)
0:18 Constant:
0:18 20 (const int)
0:18 20.000000
0:19 move second child to first child (temp float)
0:19 'result' (noContraction temp float)
0:19 Convert int to float (temp float)
0:19 move second child to first child (temp int)
0:19 'a' (noContraction temp int)
0:19 add (noContraction temp int)
0:19 'b' (noContraction temp int)
0:19 move second child to first child (temp float)
0:19 'a' (noContraction temp float)
0:19 add (noContraction temp float)
0:19 'b' (noContraction temp float)
0:19 Constant:
0:19 4 (const int)
0:19 4.000000
0:22 Function Definition: convert( (global void)
0:22 Function Parameters:
0:? Sequence
0:24 Sequence
0:24 move second child to first child (temp int)
0:24 'a' (noContraction temp int)
0:24 move second child to first child (temp float)
0:24 'a' (noContraction temp float)
0:24 Constant:
0:24 10 (const int)
0:24 10.000000
0:25 Sequence
0:25 move second child to first child (temp int)
0:25 'b' (noContraction temp int)
0:25 move second child to first child (temp float)
0:25 'b' (noContraction temp float)
0:25 Constant:
0:25 20 (const int)
0:26 move second child to first child (temp int)
0:26 'b' (noContraction temp int)
0:26 add (noContraction temp int)
0:26 'a' (noContraction temp int)
0:26 'b' (noContraction temp int)
0:27 move second child to first child (temp float)
0:27 'result' (noContraction temp float)
0:27 Convert int to float (temp float)
0:27 'b' (noContraction temp int)
0:25 20.000000
0:26 move second child to first child (temp float)
0:26 'b' (noContraction temp float)
0:26 add (noContraction temp float)
0:26 'a' (noContraction temp float)
0:26 'b' (noContraction temp float)
0:27 move second child to first child (temp double)
0:27 'result' (noContraction temp double)
0:27 Convert float to double (temp double)
0:27 'b' (noContraction temp float)
0:30 Function Definition: loop_for( (global float)
0:30 Function Parameters:
0:31 Sequence
@ -168,12 +167,7 @@ vertices = -1
0:42 'r2' (noContraction temp float)
0:45 Function Definition: loop_array( (global void)
0:45 Function Parameters:
0:46 Sequence
0:46 Sequence
0:46 move second child to first child (temp int)
0:46 'result' (noContraction temp int)
0:46 Constant:
0:46 5 (const int)
0:? Sequence
0:48 Sequence
0:48 move second child to first child (temp int)
0:48 'x' (noContraction temp int)
@ -184,10 +178,12 @@ vertices = -1
0:49 'y' (noContraction temp int)
0:49 Constant:
0:49 33 (const int)
0:52 add second child into first child (noContraction temp int)
0:52 'result' (noContraction temp int)
0:52 add (noContraction temp int)
0:52 add second child into first child (noContraction temp float)
0:52 'result' (noContraction temp float)
0:52 add (noContraction temp float)
0:52 Convert int to float (temp float)
0:52 'x' (noContraction temp int)
0:52 Convert int to float (temp float)
0:52 'y' (noContraction temp int)
0:54 Sequence
0:54 Sequence
@ -203,23 +199,23 @@ vertices = -1
0:54 3 (const int)
0:54 Loop Body
0:56 Sequence
0:56 add second child into first child (noContraction temp int)
0:56 'result' (noContraction temp int)
0:56 add (noContraction temp int)
0:56 indirect index (noContraction temp int)
0:56 'a0' (temp 3-element array of int)
0:56 add second child into first child (noContraction temp float)
0:56 'result' (noContraction temp float)
0:56 add (noContraction temp float)
0:56 indirect index (noContraction temp float)
0:56 'a0' (temp 3-element array of float)
0:56 'i' (temp int)
0:56 Constant:
0:56 2 (const int)
0:58 move second child to first child (temp int)
0:58 indirect index (noContraction temp int)
0:58 'a0' (noContraction temp 3-element array of int)
0:56 2.000000
0:58 move second child to first child (temp float)
0:58 indirect index (noContraction temp float)
0:58 'a0' (noContraction temp 3-element array of float)
0:58 'i' (temp int)
0:58 subtract (noContraction temp int)
0:58 subtract (noContraction temp float)
0:58 Constant:
0:58 3 (const int)
0:58 Post-Increment (noContraction temp int)
0:58 'result' (noContraction temp int)
0:58 3.000000
0:58 Post-Increment (noContraction temp float)
0:58 'result' (noContraction temp float)
0:54 Loop Terminal Expression
0:54 Pre-Increment (temp int)
0:54 'i' (temp int)
@ -259,8 +255,8 @@ vertices = -1
0:69 move second child to first child (temp float)
0:69 'result' (noContraction temp float)
0:69 Convert int to float (temp float)
0:69 add (noContraction temp int)
0:69 add (noContraction temp int)
0:69 add (temp int)
0:69 add (temp int)
0:69 'a' (noContraction temp int)
0:69 'b' (noContraction temp int)
0:69 Constant:
@ -444,46 +440,45 @@ vertices = -1
0:16 Constant:
0:16 5.000000
0:17 Sequence
0:17 move second child to first child (temp int)
0:17 'a' (noContraction temp int)
0:17 move second child to first child (temp float)
0:17 'a' (noContraction temp float)
0:17 Constant:
0:17 10 (const int)
0:17 10.000000
0:18 Sequence
0:18 move second child to first child (temp int)
0:18 'b' (noContraction temp int)
0:18 move second child to first child (temp float)
0:18 'b' (noContraction temp float)
0:18 Constant:
0:18 20 (const int)
0:18 20.000000
0:19 move second child to first child (temp float)
0:19 'result' (noContraction temp float)
0:19 Convert int to float (temp float)
0:19 move second child to first child (temp int)
0:19 'a' (noContraction temp int)
0:19 add (noContraction temp int)
0:19 'b' (noContraction temp int)
0:19 move second child to first child (temp float)
0:19 'a' (noContraction temp float)
0:19 add (noContraction temp float)
0:19 'b' (noContraction temp float)
0:19 Constant:
0:19 4 (const int)
0:19 4.000000
0:22 Function Definition: convert( (global void)
0:22 Function Parameters:
0:? Sequence
0:24 Sequence
0:24 move second child to first child (temp int)
0:24 'a' (noContraction temp int)
0:24 move second child to first child (temp float)
0:24 'a' (noContraction temp float)
0:24 Constant:
0:24 10 (const int)
0:24 10.000000
0:25 Sequence
0:25 move second child to first child (temp int)
0:25 'b' (noContraction temp int)
0:25 move second child to first child (temp float)
0:25 'b' (noContraction temp float)
0:25 Constant:
0:25 20 (const int)
0:26 move second child to first child (temp int)
0:26 'b' (noContraction temp int)
0:26 add (noContraction temp int)
0:26 'a' (noContraction temp int)
0:26 'b' (noContraction temp int)
0:27 move second child to first child (temp float)
0:27 'result' (noContraction temp float)
0:27 Convert int to float (temp float)
0:27 'b' (noContraction temp int)
0:25 20.000000
0:26 move second child to first child (temp float)
0:26 'b' (noContraction temp float)
0:26 add (noContraction temp float)
0:26 'a' (noContraction temp float)
0:26 'b' (noContraction temp float)
0:27 move second child to first child (temp double)
0:27 'result' (noContraction temp double)
0:27 Convert float to double (temp double)
0:27 'b' (noContraction temp float)
0:30 Function Definition: loop_for( (global float)
0:30 Function Parameters:
0:31 Sequence
@ -557,12 +552,7 @@ vertices = -1
0:42 'r2' (noContraction temp float)
0:45 Function Definition: loop_array( (global void)
0:45 Function Parameters:
0:46 Sequence
0:46 Sequence
0:46 move second child to first child (temp int)
0:46 'result' (noContraction temp int)
0:46 Constant:
0:46 5 (const int)
0:? Sequence
0:48 Sequence
0:48 move second child to first child (temp int)
0:48 'x' (noContraction temp int)
@ -573,10 +563,12 @@ vertices = -1
0:49 'y' (noContraction temp int)
0:49 Constant:
0:49 33 (const int)
0:52 add second child into first child (noContraction temp int)
0:52 'result' (noContraction temp int)
0:52 add (noContraction temp int)
0:52 add second child into first child (noContraction temp float)
0:52 'result' (noContraction temp float)
0:52 add (noContraction temp float)
0:52 Convert int to float (temp float)
0:52 'x' (noContraction temp int)
0:52 Convert int to float (temp float)
0:52 'y' (noContraction temp int)
0:54 Sequence
0:54 Sequence
@ -592,23 +584,23 @@ vertices = -1
0:54 3 (const int)
0:54 Loop Body
0:56 Sequence
0:56 add second child into first child (noContraction temp int)
0:56 'result' (noContraction temp int)
0:56 add (noContraction temp int)
0:56 indirect index (noContraction temp int)
0:56 'a0' (temp 3-element array of int)
0:56 add second child into first child (noContraction temp float)
0:56 'result' (noContraction temp float)
0:56 add (noContraction temp float)
0:56 indirect index (noContraction temp float)
0:56 'a0' (temp 3-element array of float)
0:56 'i' (temp int)
0:56 Constant:
0:56 2 (const int)
0:58 move second child to first child (temp int)
0:58 indirect index (noContraction temp int)
0:58 'a0' (noContraction temp 3-element array of int)
0:56 2.000000
0:58 move second child to first child (temp float)
0:58 indirect index (noContraction temp float)
0:58 'a0' (noContraction temp 3-element array of float)
0:58 'i' (temp int)
0:58 subtract (noContraction temp int)
0:58 subtract (noContraction temp float)
0:58 Constant:
0:58 3 (const int)
0:58 Post-Increment (noContraction temp int)
0:58 'result' (noContraction temp int)
0:58 3.000000
0:58 Post-Increment (noContraction temp float)
0:58 'result' (noContraction temp float)
0:54 Loop Terminal Expression
0:54 Pre-Increment (temp int)
0:54 'i' (temp int)
@ -648,8 +640,8 @@ vertices = -1
0:69 move second child to first child (temp float)
0:69 'result' (noContraction temp float)
0:69 Convert int to float (temp float)
0:69 add (noContraction temp int)
0:69 add (noContraction temp int)
0:69 add (temp int)
0:69 add (temp int)
0:69 'a' (noContraction temp int)
0:69 'b' (noContraction temp int)
0:69 Constant:

View File

@ -325,8 +325,8 @@ Shader version: 450
0:63 0 (const int)
0:63 'k' (temp int)
0:63 Convert int to float (temp float)
0:63 add (noContraction temp int)
0:63 component-wise multiply (noContraction temp int)
0:63 add (temp int)
0:63 component-wise multiply (temp int)
0:63 'i' (noContraction temp int)
0:63 'j' (noContraction temp int)
0:63 'k' (noContraction temp int)
@ -848,8 +848,8 @@ Shader version: 450
0:63 0 (const int)
0:63 'k' (temp int)
0:63 Convert int to float (temp float)
0:63 add (noContraction temp int)
0:63 component-wise multiply (noContraction temp int)
0:63 add (temp int)
0:63 component-wise multiply (temp int)
0:63 'i' (noContraction temp int)
0:63 'j' (noContraction temp int)
0:63 'k' (noContraction temp int)

View File

@ -14,17 +14,17 @@ float minimal() {
void continuous_assignment() {
precise float result = 5.0;
int a = 10;
int b = 20;
float a = 10.0;
float b = 20.0;
result = a = b + 4; // b + 4 should be 'noContraction'.
}
void convert() {
precise float result;
int a = 10;
int b = 20;
precise double result;
float a = 10.0;
float b = 20.0;
b = a + b; // a + b should be 'noContraction'.
result = float(b); // convert operation should not be 'noContraction'.
result = double(b); // convert operation should not be 'noContraction'.
}
float loop_for() {
@ -43,13 +43,13 @@ float loop_for() {
}
void loop_array(void) {
precise int result = 5;
precise float result;
int x = 22;
int y = 33;
int a0[3];
result += x + y; // x + y should be 'noContraction' also result + rvalue.
float a0[3];
result += float(x) + float(y); // x + y should be 'noContraction' also result + rvalue.
for (int i = 0; i < 3; ++i) {
// a's dereference + 2 should be 'noContraction'.
@ -66,7 +66,7 @@ void loop_while() {
while (result < 10) {
result += 3.12 + b; // result + 3.12 should be 'noContraction'.
}
result = a + b + 5; // b + 5 should be 'noCtraction' and also a + rvalue.
result = a + b + 5; // b + 5 should not be 'noCtraction' because all operands are integers.
result = 11.1;
}

View File

@ -60,7 +60,7 @@ float complex_array_struct() {
for(int j=0; j<6; j++) {
for(int k = 0; k<3; k++) {
t3[i].t2.t1c[j].t1_array[k] = i * j + k; // NoContraction
t3[i].t2.t1c[j].t1_array[k] = i * j + k; // Not NoContraction because all operands are integers
}
t3[i].t2.t1c[j].t1_scalar = j * 2.0 / i; // Not NoContraction
}

View File

@ -712,7 +712,7 @@ protected:
return false;
}
// If this is an arithmetic operation, marks this node as 'noContraction'.
if (isArithmeticOperation(node->getOp())) {
if (isArithmeticOperation(node->getOp()) && node->getBasicType() != glslang::EbtInt) {
node->getWritableType().getQualifier().noContraction = true;
}
// As this node is not an object node, need to traverse the children nodes.