]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/loop-unroll.c
Merge with trunk.
[thirdparty/gcc.git] / gcc / loop-unroll.c
index 557915fafbc16c6eb12d15f34bcb77e9e9b56c07..b8df05b390a4d4da53a6fdd9940ade2de3aa1a2d 100644 (file)
@@ -641,7 +641,7 @@ decide_unroll_constant_iterations (struct loop *loop, int flags)
 {
   unsigned nunroll, nunroll_by_av, best_copies, best_unroll = 0, n_copies, i;
   struct niter_desc *desc;
-  double_int iterations;
+  widest_int iterations;
 
   if (!(flags & UAP_UNROLL))
     {
@@ -694,7 +694,7 @@ decide_unroll_constant_iterations (struct loop *loop, int flags)
   if (desc->niter < 2 * nunroll
       || ((get_estimated_loop_iterations (loop, &iterations)
           || get_max_loop_iterations (loop, &iterations))
-         && iterations.ult (double_int::from_shwi (2 * nunroll))))
+         && wi::ltu_p (iterations, 2 * nunroll)))
     {
       if (dump_file)
        fprintf (dump_file, ";; Not unrolling loop, doesn't roll\n");
@@ -814,11 +814,10 @@ unroll_loop_constant_iterations (struct loop *loop)
 
          desc->noloop_assumptions = NULL_RTX;
          desc->niter -= exit_mod;
-         loop->nb_iterations_upper_bound -= double_int::from_uhwi (exit_mod);
+         loop->nb_iterations_upper_bound -= exit_mod;
          if (loop->any_estimate
-             && double_int::from_uhwi (exit_mod).ule
-                  (loop->nb_iterations_estimate))
-           loop->nb_iterations_estimate -= double_int::from_uhwi (exit_mod);
+             && wi::leu_p (exit_mod, loop->nb_iterations_estimate))
+           loop->nb_iterations_estimate -= exit_mod;
          else
            loop->any_estimate = false;
        }
@@ -858,11 +857,10 @@ unroll_loop_constant_iterations (struct loop *loop)
            apply_opt_in_copies (opt_info, exit_mod + 1, false, false);
 
          desc->niter -= exit_mod + 1;
-         loop->nb_iterations_upper_bound -= double_int::from_uhwi (exit_mod + 1);
+         loop->nb_iterations_upper_bound -= exit_mod + 1;
          if (loop->any_estimate
-             && double_int::from_uhwi (exit_mod + 1).ule
-                  (loop->nb_iterations_estimate))
-           loop->nb_iterations_estimate -= double_int::from_uhwi (exit_mod + 1);
+             && wi::leu_p (exit_mod + 1, loop->nb_iterations_estimate))
+           loop->nb_iterations_estimate -= exit_mod + 1;
          else
            loop->any_estimate = false;
          desc->noloop_assumptions = NULL_RTX;
@@ -914,14 +912,10 @@ unroll_loop_constant_iterations (struct loop *loop)
 
   desc->niter /= max_unroll + 1;
   loop->nb_iterations_upper_bound
-    = loop->nb_iterations_upper_bound.udiv (double_int::from_uhwi (max_unroll
-                                                                  + 1),
-                                           TRUNC_DIV_EXPR);
+    = wi::udiv_trunc (loop->nb_iterations_upper_bound, max_unroll + 1);
   if (loop->any_estimate)
     loop->nb_iterations_estimate
-      = loop->nb_iterations_estimate.udiv (double_int::from_uhwi (max_unroll
-                                                                 + 1),
-                                          TRUNC_DIV_EXPR);
+      = wi::udiv_trunc (loop->nb_iterations_estimate, max_unroll + 1);
   desc->niter_expr = GEN_INT (desc->niter);
 
   /* Remove the edges.  */
@@ -941,7 +935,7 @@ decide_unroll_runtime_iterations (struct loop *loop, int flags)
 {
   unsigned nunroll, nunroll_by_av, i;
   struct niter_desc *desc;
-  double_int iterations;
+  widest_int iterations;
 
   if (!(flags & UAP_UNROLL))
     {
@@ -997,7 +991,7 @@ decide_unroll_runtime_iterations (struct loop *loop, int flags)
   /* Check whether the loop rolls.  */
   if ((get_estimated_loop_iterations (loop, &iterations)
        || get_max_loop_iterations (loop, &iterations))
-      && iterations.ult (double_int::from_shwi (2 * nunroll)))
+      && wi::ltu_p (iterations, 2 * nunroll))
     {
       if (dump_file)
        fprintf (dump_file, ";; Not unrolling loop, doesn't roll\n");
@@ -1304,14 +1298,10 @@ unroll_loop_runtime_iterations (struct loop *loop)
     simplify_gen_binary (UDIV, desc->mode, old_niter,
                         gen_int_mode (max_unroll + 1, desc->mode));
   loop->nb_iterations_upper_bound
-    = loop->nb_iterations_upper_bound.udiv (double_int::from_uhwi (max_unroll
-                                                                  + 1),
-                                           TRUNC_DIV_EXPR);
+    = wi::udiv_trunc (loop->nb_iterations_upper_bound, max_unroll + 1);
   if (loop->any_estimate)
     loop->nb_iterations_estimate
-      = loop->nb_iterations_estimate.udiv (double_int::from_uhwi (max_unroll
-                                                                 + 1),
-                                          TRUNC_DIV_EXPR);
+      = wi::udiv_trunc (loop->nb_iterations_estimate, max_unroll + 1);
   if (exit_at_end)
     {
       desc->niter_expr =
@@ -1319,7 +1309,7 @@ unroll_loop_runtime_iterations (struct loop *loop)
       desc->noloop_assumptions = NULL_RTX;
       --loop->nb_iterations_upper_bound;
       if (loop->any_estimate
-         && loop->nb_iterations_estimate != double_int_zero)
+         && loop->nb_iterations_estimate != 0)
        --loop->nb_iterations_estimate;
       else
        loop->any_estimate = false;
@@ -1337,7 +1327,7 @@ static void
 decide_peel_simple (struct loop *loop, int flags)
 {
   unsigned npeel;
-  double_int iterations;
+  widest_int iterations;
 
   if (!(flags & UAP_PEEL))
     {
@@ -1381,7 +1371,8 @@ decide_peel_simple (struct loop *loop, int flags)
   /* If we have realistic estimate on number of iterations, use it.  */
   if (get_estimated_loop_iterations (loop, &iterations))
     {
-      if (double_int::from_shwi (npeel).ule (iterations))
+      /* TODO: unsigned/signed confusion */
+      if (wi::leu_p (npeel, iterations))
        {
          if (dump_file)
            {
@@ -1398,7 +1389,7 @@ decide_peel_simple (struct loop *loop, int flags)
   /* If we have small enough bound on iterations, we can still peel (completely
      unroll).  */
   else if (get_max_loop_iterations (loop, &iterations)
-           && iterations.ult (double_int::from_shwi (npeel)))
+           && wi::ltu_p (iterations, npeel))
     npeel = iterations.to_shwi () + 1;
   else
     {
@@ -1492,7 +1483,7 @@ decide_unroll_stupid (struct loop *loop, int flags)
 {
   unsigned nunroll, nunroll_by_av, i;
   struct niter_desc *desc;
-  double_int iterations;
+  widest_int iterations;
 
   if (!(flags & UAP_UNROLL_ALL))
     {
@@ -1549,7 +1540,7 @@ decide_unroll_stupid (struct loop *loop, int flags)
   /* Check whether the loop rolls.  */
   if ((get_estimated_loop_iterations (loop, &iterations)
        || get_max_loop_iterations (loop, &iterations))
-      && iterations.ult (double_int::from_shwi (2 * nunroll)))
+      && wi::ltu_p (iterations, 2 * nunroll))
     {
       if (dump_file)
        fprintf (dump_file, ";; Not unrolling loop, doesn't roll\n");