nir: fix loop iteration count calculation for floats
authorTimothy Arceri <timothy.arceri@collabora.com>
Tue, 3 Jan 2017 01:03:54 +0000 (12:03 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Wed, 4 Jan 2017 03:48:36 +0000 (14:48 +1100)
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)
      ...

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/nir/nir_loop_analyze.c

index 71cbe3c5a8dcf3d3a2f2f8a46b239c1e1a4507de..a5f464a45d11d86577e1b1523deb4a5252cddc98 100644 (file)
@@ -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;
    }