public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/kubaneko/heads/histogram)] fixed a bug
@ 2023-04-07 10:20 Ondrej Kubanek
  0 siblings, 0 replies; only message in thread
From: Ondrej Kubanek @ 2023-04-07 10:20 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:801734b5a5cb5b9abe281fafbc860c29b95d09ea

commit 801734b5a5cb5b9abe281fafbc860c29b95d09ea
Author: kubaneko <kubanek0ondrej@gmail.com>
Date:   Fri Apr 7 10:20:08 2023 +0000

    fixed a bug

Diff:
---
 gcc/loop-unroll.cc           | 20 +++++++++++++++-----
 gcc/tree-ssa-loop-ivcanon.cc |  6 +++++-
 gcc/tree-vect-loop.cc        |  6 ++++--
 3 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/gcc/loop-unroll.cc b/gcc/loop-unroll.cc
index eea18471775..4a9d6fbcf19 100644
--- a/gcc/loop-unroll.cc
+++ b/gcc/loop-unroll.cc
@@ -533,7 +533,9 @@ unroll_loop_constant_iterations (class loop *loop)
 	  desc->noloop_assumptions = NULL_RTX;
 	  desc->niter -= exit_mod;
 	  loop->nb_iterations_upper_bound -= exit_mod;
-      histogram_counters_minus_upper_bound(loop->counters,exit_mod);
+      if (loop->counters){
+          histogram_counters_minus_upper_bound(loop->counters,exit_mod);
+      }
 	  if (loop->any_estimate
 	      && wi::leu_p (exit_mod, loop->nb_iterations_estimate))
 	    loop->nb_iterations_estimate -= exit_mod;
@@ -579,7 +581,9 @@ unroll_loop_constant_iterations (class loop *loop)
 
 	  desc->niter -= exit_mod + 1;
 	  loop->nb_iterations_upper_bound -= exit_mod + 1;
-      histogram_counters_minus_upper_bound(loop->counters,exit_mod+1);
+      if (loop->counters){
+          histogram_counters_minus_upper_bound(loop->counters,exit_mod+1);
+      }
 	  if (loop->any_estimate
 	      && wi::leu_p (exit_mod + 1, loop->nb_iterations_estimate))
 	    loop->nb_iterations_estimate -= exit_mod + 1;
@@ -634,7 +638,9 @@ unroll_loop_constant_iterations (class loop *loop)
   desc->niter /= max_unroll + 1;
   loop->nb_iterations_upper_bound
     = wi::udiv_trunc (loop->nb_iterations_upper_bound, max_unroll + 1);
-  histogram_counters_div_upper_bound(loop->counters,exit_mod);
+  if (loop->counters){
+      histogram_counters_div_upper_bound(loop->counters,exit_mod);
+  }
   if (loop->any_estimate)
     loop->nb_iterations_estimate
       = wi::udiv_trunc (loop->nb_iterations_estimate, max_unroll + 1);
@@ -1098,7 +1104,9 @@ unroll_loop_runtime_iterations (class loop *loop)
 			 gen_int_mode (max_unroll + 1, desc->mode));
   loop->nb_iterations_upper_bound
     = wi::udiv_trunc (loop->nb_iterations_upper_bound, max_unroll + 1);
-  histogram_counters_div_upper_bound(loop->counters, max_unroll + 1);
+  if (loop->counters){
+      histogram_counters_div_upper_bound(loop->counters, max_unroll + 1);
+  }
   if (loop->any_estimate)
     loop->nb_iterations_estimate
       = wi::udiv_trunc (loop->nb_iterations_estimate, max_unroll + 1);
@@ -1111,7 +1119,9 @@ unroll_loop_runtime_iterations (class loop *loop)
 	simplify_gen_binary (MINUS, desc->mode, desc->niter_expr, const1_rtx);
       desc->noloop_assumptions = NULL_RTX;
       --loop->nb_iterations_upper_bound;
-      histogram_counters_minus_upper_bound(loop->counters,1);
+      if (loop->counters){
+          histogram_counters_minus_upper_bound(loop->counters,1);
+      }
       if (loop->any_estimate
 	  && loop->nb_iterations_estimate != 0)
 	--loop->nb_iterations_estimate;
diff --git a/gcc/tree-ssa-loop-ivcanon.cc b/gcc/tree-ssa-loop-ivcanon.cc
index 83b5a890439..46722e63a48 100644
--- a/gcc/tree-ssa-loop-ivcanon.cc
+++ b/gcc/tree-ssa-loop-ivcanon.cc
@@ -1147,6 +1147,7 @@ try_peel_loop (class loop *loop,
       fprintf (dump_file, "Peeled loop %d, %i times.\n",
 	       loop->num, (int) npeel);
     }
+  // ASLJKJLDSADHASDLJASKLDJASLKDJLSAKJDDSALJDSLK
   if (loop->any_estimate)
     {
       if (wi::ltu_p (npeel, loop->nb_iterations_estimate))
@@ -1156,12 +1157,14 @@ try_peel_loop (class loop *loop,
     }
   if (loop->any_upper_bound)
     {
-      histogram_counters_minus_upper_bound(loop->counters,npeel);
       if (wi::ltu_p (npeel, loop->nb_iterations_upper_bound))
         loop->nb_iterations_upper_bound -= npeel;
       else
         loop->nb_iterations_upper_bound = 0;
     }
+  if (loop->counters){
+       histogram_counters_minus_upper_bound(loop->counters,npeel);
+  }
   if (loop->any_likely_upper_bound)
     {
       if (wi::ltu_p (npeel, loop->nb_iterations_likely_upper_bound))
@@ -1173,6 +1176,7 @@ try_peel_loop (class loop *loop,
 	  loop->nb_iterations_likely_upper_bound = 0;
 	}
     }
+
   profile_count entry_count = profile_count::zero ();
 
   edge e;
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index cc2ed78b52e..bbfd1987f07 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -11056,6 +11056,10 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple *loop_vectorized_call)
       bias_for_lowest += lowest_vf - min_first_active;
       bias_for_assumed += assumed_vf - min_first_active;
     }
+  if (loop->counters){
+    histogram_counters_div_upper_bound(loop->counters,lowest_vf);
+    histogram_counters_minus_upper_bound(loop->counters,1);
+  }
   /* In these calculations the "- 1" converts loop iteration counts
      back to latch counts.  */
   if (loop->any_upper_bound)
@@ -11067,8 +11071,6 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple *loop_vectorized_call)
 			    lowest_vf) - 1
 	   : wi::udiv_floor (loop->nb_iterations_upper_bound + bias_for_lowest,
 			     lowest_vf) - 1);
-    histogram_counters_div_upper_bound(loop->counters,lowest_vf);
-    histogram_counters_minus_upper_bound(loop->counters,1);
       if (main_vinfo
 	  /* Both peeling for alignment and peeling for gaps can end up
 	     with the scalar epilogue running for more than VF-1 iterations.  */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-07 10:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-07 10:20 [gcc(refs/users/kubaneko/heads/histogram)] fixed a bug Ondrej Kubanek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).