[Mesa-dev] [PATCH] nir: fix loop iteration count calculation for floats

Timothy Arceri timothy.arceri at collabora.com
Wed Jan 4 22:32:29 UTC 2017


On Wed, 2017-01-04 at 06:50 -0800, Jason Ekstrand wrote:
> On Jan 4, 2017 4:39 AM, "Eero Tamminen" <eero.t.tamminen at intel.com>
> wrote:
> Hi,
> 
> Tested-by: Eero Tamminen <eero.t.tamminen at intel.com>
> 
> May also impact other programs having float indexed loops:
> - Invisible Inc
> - Talos Principle
> 
> I think I saw most Talos loops get unrolled.  There was one or two
> that didn't but I think that was because they had a *lot* of
> instructions inside the loop.

Yeah I have all of these in my shader-db and there were no regressions
vs GLSL IR when I pushed the series so they were all probably doing
things like:

for (float i = 0.0; i < 5.0; i+=1.0)

Which would have worked fine in the buggy code.

> 
> - Steam Big Picture
> - Serious Sam 3
> 
> 
>         - Eero
> 
> 
> On 04.01.2017 02:59, Timothy Arceri wrote:
> > Fixes performance regression in SynMark PSPom caused by loops with
> > float
> > counters not always unrolling.
> > 
> > For example:
> > 
> >    for (float i = 0.02; i < 0.9; i += 0.11)
> >       ...
> > ---
> >  src/compiler/nir/nir_loop_analyze.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/src/compiler/nir/nir_loop_analyze.c
> > b/src/compiler/nir/nir_loop_analyze.c
> > index 71cbe3c..a5f464a 100644
> > --- a/src/compiler/nir/nir_loop_analyze.c
> > +++ b/src/compiler/nir/nir_loop_analyze.c
> > @@ -384,8 +384,8 @@ get_iteration(nir_op cond_op, nir_const_value
> > *initial, nir_const_value *step,
> >     case nir_op_flt:
> >     case nir_op_feq:
> >     case nir_op_fne: {
> > -      int32_t initial_val = initial->f32[0];
> > -      int32_t span = limit->f32[0] - initial_val;
> > +      float initial_val = initial->f32[0];
> > +      float span = limit->f32[0] - initial_val;
> >        iter = span / step->f32[0];
> >        break;
> >     }
> > 
> > 
>  
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list