This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[CFG] PRED_CFG_LOOP_ITERATIONS fix


Hello.

This patch fixes weird placement of test for PRED_CFG_LOOP_ITERATIONS
predictor aplicability that caused us to invoke simple_loop_p once
for each basic block in the loop.

I'm commiting the change to cfg branch.

Zdenek

Changelog:
	* predict.c (estimate_probability): Change position of simple_loop_p
	test.

Index: predict.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/predict.c,v
retrieving revision 1.44.2.35
diff -c -3 -p -r1.44.2.35 predict.c
*** predict.c	6 Jun 2002 21:16:31 -0000	1.44.2.35
--- predict.c	14 Jun 2002 19:06:01 -0000
*************** estimate_probability (loops_info)
*** 427,453 ****
        int j;
        int exits;
        struct loop *loop = loops_info->parray[i];
  
        flow_loop_scan (loops_info, loop, LOOP_EXIT_EDGES);
        exits = loop->num_exits;
  
        bbs = get_loop_body (loop);
        for (j = 0; j < loop->num_nodes; j++)
  	{
  	  int header_found = 0;
  	  edge e;
- 	  struct loop_desc desc;
  
  	  bb = bbs[j];
- 
- 	  if (simple_loop_p (loops_info, loop, &desc)
- 	      && desc.const_iter)
- 	    {
- 	      predict_edge (desc.in_edge, PRED_CFG_LOOP_ITERATIONS,
- 			    REG_BR_PROB_BASE
- 			    - (REG_BR_PROB_BASE + (desc.niter + 1) /2)
- 			    / (desc.niter + 1));
- 	    }
  
  	  /* Bypass loop heuristics on continue statement.  These
  	     statements construct loops via "non-loop" constructs
--- 427,453 ----
        int j;
        int exits;
        struct loop *loop = loops_info->parray[i];
+       struct loop_desc desc;
  
        flow_loop_scan (loops_info, loop, LOOP_EXIT_EDGES);
        exits = loop->num_exits;
  
+       if (simple_loop_p (loops_info, loop, &desc)
+ 	  && desc.const_iter)
+ 	{
+ 	  predict_edge (desc.in_edge, PRED_CFG_LOOP_ITERATIONS,
+ 			REG_BR_PROB_BASE
+ 			- (REG_BR_PROB_BASE + (desc.niter + 1) /2)
+ 			/ (desc.niter + 1));
+ 	}
+ 
        bbs = get_loop_body (loop);
        for (j = 0; j < loop->num_nodes; j++)
  	{
  	  int header_found = 0;
  	  edge e;
  
  	  bb = bbs[j];
  
  	  /* Bypass loop heuristics on continue statement.  These
  	     statements construct loops via "non-loop" constructs


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]