+2012-08-02  Mikael Morin  <mikael@gcc.gnu.org>
+
+       * trans-array.c (set_loop_bounds): Remove useless dimension check.
+       Don't update loopspec if it would loose the wanted stride criterion.
+
 2012-08-02  Mikael Morin  <mikael@gcc.gnu.org>
 
        * trans-array.h (gfc_conv_descriptor_rank): New prototype.
 
             known lower bound
             known upper bound
           */
-         else if ((loopspec[n]->info->type == GFC_SS_CONSTRUCTOR && dynamic[n])
-                  || n >= loop->dimen)
+         else if (loopspec[n]->info->type == GFC_SS_CONSTRUCTOR && dynamic[n])
            loopspec[n] = ss;
          else if (integer_onep (info->stride[dim])
                   && !integer_onep (specinfo->stride[spec_dim]))
                   && !INTEGER_CST_P (specinfo->stride[spec_dim]))
            loopspec[n] = ss;
          else if (INTEGER_CST_P (info->start[dim])
-                  && !INTEGER_CST_P (specinfo->start[spec_dim]))
+                  && !INTEGER_CST_P (specinfo->start[spec_dim])
+                  && integer_onep (info->stride[dim])
+                     == integer_onep (specinfo->stride[dim])
+                  && INTEGER_CST_P (info->stride[dim])
+                     == INTEGER_CST_P (specinfo->stride[dim]))
            loopspec[n] = ss;
          /* We don't work out the upper bound.
             else if (INTEGER_CST_P (info->finish[n])