Change the FLATTEN heuristic to "ifs with a loop with a gradient"

This heuristic makes more sense than the previous "ifs with a
discontinuous loop" as the reason we need to flatten is that we need
gradients to be in branchless code.

Change the UnrollFlatten test accordingly.

Tested with:
 - the WebGL CTS
 - dev.miaumiau.cat/rayTracer "Skull Demo"
 - THe turbulenz engine GPU particle demo
 - Lots of ShaderToy Samples (inc. Volcanic, Metropolis and Hierarchical
   Voronoi)
 - Google Maps Earth mode
 - Lots of Chrome experiments
 - madebyevan.com/webgl-water

BUG=524297

Change-Id: Iaa727036fffcfde3952716a1ef33b6ee0546b69d
Reviewed-on: https://chromium-review.googlesource.com/296442
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/compiler/translator/OutputHLSL.cpp b/src/compiler/translator/OutputHLSL.cpp
index e03c39e..d6b9a55 100644
--- a/src/compiler/translator/OutputHLSL.cpp
+++ b/src/compiler/translator/OutputHLSL.cpp
@@ -2374,9 +2374,7 @@
     }
 
     // D3D errors when there is a gradient operation in a loop in an unflattened if.
-    if (mShaderType == GL_FRAGMENT_SHADER &&
-        mCurrentFunctionMetadata->hasDiscontinuousLoop(node) &&
-        mCurrentFunctionMetadata->hasGradientInCallGraph(node))
+    if (mShaderType == GL_FRAGMENT_SHADER && mCurrentFunctionMetadata->hasGradientLoop(node))
     {
         out << "FLATTEN ";
     }