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/+/36708
Tested-by: Sean Risser <srisser@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/OpenGL/compiler/ParseHelper.cpp b/src/OpenGL/compiler/ParseHelper.cpp
index b46a36f..2bee48e 100644
--- a/src/OpenGL/compiler/ParseHelper.cpp
+++ b/src/OpenGL/compiler/ParseHelper.cpp
@@ -3669,6 +3669,16 @@
 									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;
+								}
+							}
 						}
 					}
 				}