Use the [[flatten]] attribute only when a loop is present.

Flattening branch-heavy shaders that contained no loops caused regressions.
As a temporary workaround we only flatten ifs when there exists a loop.

BUG=395048

Change-Id: I95c40f0249643b98c62304a0f2a4563561d1fbbc
Reviewed-on: https://chromium-review.googlesource.com/228722
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Tested-by: Corentin Wallez <cwallez@chromium.org>