Commit a9dc7707 by Sean Risser

Optimize "max(t, t)" to fold into just "t"

This masks a crash related to nested, unconditional continue statements. Those constructs are known to be buggy, but we have elected to not fix them at this point in time because the SWANGLE project will deprecate all of Swiftshader's GLES backend. It's unlikely that the remaining bug will effect many end-users as it relies on bizarre control flow. For logging purposes here is the shader code that reproduces an infinite loop: void foo() { } void main() { for (int i = 0; i < 4; i++) { continue; for (int k = 0; k < 4; k++) continue; foo(); } } I'm not adding this as a unit test since we aren't fixing our compiler. Bug chromium:997283 Change-Id: Id31d70c4cd70a16fd20b7ebed18a82d5f8a705ba Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/36708Tested-by: 's avatarSean Risser <srisser@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 8b693854
......@@ -3669,6 +3669,16 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall, TIntermN
callNode = typedReturnNode;
}
}
else if (op == EOpMax || op == EOpMin)
{
TIntermSymbol *leftSymbol = left->getAsSymbolNode();
TIntermSymbol *rightSymbol = right->getAsSymbolNode();
if (leftSymbol && rightSymbol && leftSymbol->getId() == rightSymbol->getId())
{
callNode = left;
}
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment