Problem in propagating profiling information through loop unrolling

Mostafa Hagog MUSTAFA@il.ibm.com
Wed Apr 21 13:31:00 GMT 2004


Zdenek, Jan,
I have incorporated your suggestions in the patch below.
Passed bootstrap on powerpc-apple-darwin7.2.0. I have
measured the number of times Doloop optimization was
successful over SPEC2000; following are the results:

           Before fix         After fix       Diff
164.gzip        73              75              2
175.vpr         79              83              4
176.gcc         378             378             0
181.mcf         3               3               0
186.crafty      83              85              2
197.parser      79              81              2
252.eon         0               0               0
253.perlbmk     144             145             1
254.gap         386             386             0
255.vortex      18              18              0
256.bzip2       50              51              1
300.twolf       69              69              0
168.wupwise     23              23              0
171.swim        23              30              7
172.mgrid       48              48              0
173.applu       65              65              0
177.mesa        619             620             1
178.galgel      532             551             19
179.art         46              62              16
183.equake      21              22              1
187.facerec     126             126             0
188.ammp        24              24              0
189.lucas       33              33              0
191.fma3d       0               0               0
200.sixtrack    39              39              0
301.apsi        206             206             0

Total                                           56

If this is OK for mainline, can anybody commit it?

ChangeLog

2004-04-21 Mostafa Hagog <mustafa@il.ibm.com>
      * cfgloopmanip.c (scale_bbs_frequencies): Use RDIV macro
      * cfgloopanal.c (expected_loop_iterations): Change the return value

Index: cfgloopmanip.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgloopmanip.c,v
retrieving revision 1.23
diff -c -p -r1.23 cfgloopmanip.c
*** cfgloopmanip.c      24 Feb 2004 23:39:54 -0000    1.23
--- cfgloopmanip.c      21 Apr 2004 07:47:20 -0000
*************** static void scale_bbs_frequencies (basic
*** 50,55 ****
--- 50,57 ----
  static basic_block create_preheader (struct loop *, int);
  static void fix_irreducible_loops (basic_block);

+ #define RDIV(X,Y) (((X) + (Y) / 2) / (Y))
+
  /* Splits basic block BB after INSN, returns created edge.  Updates loops
     and dominators.  */
  edge
*************** scale_bbs_frequencies (basic_block *bbs,
*** 458,464 ****
    for (i = 0; i < nbbs; i++)
      {
        bbs[i]->frequency = (bbs[i]->frequency * num) / den;
!       bbs[i]->count = (bbs[i]->count * num) / den;
        for (e = bbs[i]->succ; e; e = e->succ_next)
      e->count = (e->count * num) /den;
      }
--- 460,466 ----
    for (i = 0; i < nbbs; i++)
      {
        bbs[i]->frequency = (bbs[i]->frequency * num) / den;
!       bbs[i]->count = RDIV (bbs[i]->count * num, den);
        for (e = bbs[i]->succ; e; e = e->succ_next)
      e->count = (e->count * num) /den;
      }
*************** can_duplicate_loop_p (struct loop *loop)
*** 812,818 ****
    return ret;
  }

- #define RDIV(X,Y) (((X) + (Y) / 2) / (Y))

  /* Duplicates body of LOOP to given edge E NDUPL times.  Takes care of
updating
     LOOPS structure and dominators.  E's destination must be LOOP header
for
--- 814,819 ----
Index: cfgloopanal.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgloopanal.c,v
retrieving revision 1.23
diff -c -p -r1.23 cfgloopanal.c
*** cfgloopanal.c 18 Mar 2004 16:42:30 -0000    1.23
--- cfgloopanal.c 21 Apr 2004 07:47:20 -0000
*************** expected_loop_iterations (const struct l
*** 431,437 ****
        count_in += e->count;

        if (count_in == 0)
!     return 0;

        expected = (count_latch + count_in - 1) / count_in;

--- 431,437 ----
        count_in += e->count;

        if (count_in == 0)
!     return count_latch;

        expected = (count_latch + count_in - 1) / count_in;

*************** expected_loop_iterations (const struct l
*** 452,458 ****
        freq_in += EDGE_FREQUENCY (e);

        if (freq_in == 0)
!     return 0;

        return (freq_latch + freq_in - 1) / freq_in;
      }
--- 452,458 ----
        freq_in += EDGE_FREQUENCY (e);

        if (freq_in == 0)
!     return freq_latch;

        return (freq_latch + freq_in - 1) / freq_in;
      }




More information about the Gcc mailing list