glsl: Don't increase the iteration count when there are no terminators
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 20 Jun 2019 22:48:48 +0000 (15:48 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Mon, 24 Jun 2019 21:32:33 +0000 (14:32 -0700)
commitee1c69faddb3624ace6548dafaff50549a031380
treecb49aecd3f3727da46c96fe086790c92ce9f9413
parent5c4289dd4b3f37bc5b23b24069ee1137a6c1fa32
glsl: Don't increase the iteration count when there are no terminators

Incrementing the iteration count was intended to fix an off-by-one error
when the first terminator was superseded by a later terminator.  If
there is no first terminator or later terminator, there is no off-by-one
error.  Incrementing the loop count creates one.  This can be seen in
loops like:

    do {
        if (something) {
            // No breaks or continues here.
        }
    } while (false);

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Tested-by: Abel Briggs <abelbriggs1@hotmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110953
Fixes: 646621c66da ("glsl: make loop unrolling more like the nir unrolling path")
src/compiler/glsl/loop_unroll.cpp