This is the mail archive of the gcc@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]

regrename introduces dependencies and causes cprop_hardreg regressions


Hi,
I measured the impact of regrename on code size of benchmark CSiBE,
using following command line:

1. arm-none-eabi-gcc -mthumb -mcpu=cortex-m0 -Os
comparing to
2. arm-none-eabi-gcc -mthumb -mcpu=cortex-m0 -Os -frename-registers

And I was surprised that regrename causes many code size regressions
by introducing dependencies,
hurting cprop_hardreg pass.

Take below code as an example:

typedef struct
{
    double X, Y;
} Point;

typedef struct
{
    Point p1;
    Point c1;
    Point c2;
    Point p2;
} Curve;


double bar(double t, double p0, double p1, double p2, double p3);
void foo( Curve *curve, int count )
{
    int n;
    int step;
    Point point;
    Curve c0;
    double t;
    for ( n = 0; n < count; ++n )
    {
        c0 = curve[n];

        for ( step = 0; step < (10); ++step )
        {
            t = ((double)(step)) / (double)(10);
            point.X = bar( t, c0.p1.X, c0.c1.X, c0.c2.X, c0.p2.X );
            point.Y = bar( t, c0.p1.Y, c0.c1.Y, c0.c2.Y, c0.p2.Y );
        }
    }
}

Piece of rtl dump of pass ce3 is like:

(insn 157 80 158 4 (set (reg:SI 4 r4 [180])
        (reg:SI 0 r0)) ../office_pointio.E:29 187 {*thumb1_movsi_insn}
     (expr_list:REG_DEAD (reg:SI 0 r0)
        (nil)))

(insn 158 157 147 4 (set (reg:SI 5 r5 [+4 ])
        (reg:SI 1 r1 [+4 ])) ../office_pointio.E:29 187 {*thumb1_movsi_insn}
     (expr_list:REG_DEAD (reg:SI 1 r1 [+4 ])
        (nil)))

(insn 147 158 83 4 (set (reg:DF 2 r2)
        (mem/c:DF (plus:SI (reg/f:SI 13 sp)
                (const_int 40 [0x28])) [6 %sfp+-56 S8 A64]))
../office_pointio.E:30 205 {*thumb_movdf_insn}
     (nil))

(insn 83 147 148 4 (set (mem:DF (reg/f:SI 13 sp) [0 S8 A64])
        (reg:DF 2 r2)) ../office_pointio.E:30 205 {*thumb_movdf_insn}
     (expr_list:REG_DEAD (reg:DF 2 r2)
        (nil)))

(insn 148 83 84 4 (set (reg:DF 2 r2)
        (mem/c:DF (plus:SI (reg/f:SI 13 sp)
                (const_int 56 [0x38])) [6 %sfp+-40 S8 A64]))
../office_pointio.E:30 205 {*thumb_movdf_insn}
     (nil))

(insn 84 148 149 4 (set (mem:DF (plus:SI (reg/f:SI 13 sp)
                (const_int 8 [0x8])) [0 S8 A64])
        (reg:DF 2 r2)) ../office_pointio.E:30 205 {*thumb_movdf_insn}
     (expr_list:REG_DEAD (reg:DF 2 r2)
        (nil)))

(insn 149 84 85 4 (set (reg:DF 2 r2)
        (mem/c:DF (plus:SI (reg/f:SI 13 sp)
                (const_int 72 [0x48])) [6 %sfp+-24 S8 A64]))
../office_pointio.E:30 205 {*thumb_movdf_insn}
     (nil))

(insn 85 149 159 4 (set (mem:DF (plus:SI (reg/f:SI 13 sp)
                (const_int 16 [0x10])) [0 S8 A64])
        (reg:DF 2 r2)) ../office_pointio.E:30 205 {*thumb_movdf_insn}
     (expr_list:REG_DEAD (reg:DF 2 r2)
        (nil)))

(insn 159 85 160 4 (set (reg:SI 0 r0)
        (reg:SI 4 r4 [180])) ../office_pointio.E:30 187 {*thumb1_movsi_insn}
     (nil))

(insn 160 159 87 4 (set (reg:SI 1 r1 [+4 ])
        (reg:SI 5 r5 [+4 ])) ../office_pointio.E:30 187 {*thumb1_movsi_insn}
     (nil))

When regrename is enabled, it replaces r2 in insn147/83 with r0, relpaces r2
in insn 149/85 with r1. Introducing new dependencies resulting in redundant
insn 159/160 cannot be handled by cprop_hardreg.

The points are:
1. This regrename pass does eliminate many dependencies, but the regression
is not minority, resulting in very small benefit overall.
2. The conclusion is based on the code size and cprop_hardreg, I am not sure
how this regression affects the sched2 pass.

The question is:
1. Is it possible to fix the regression in regrename pass? or just run
an additional
cprop pass before regrename?
2. Currently regrename is only enabled along with loop unrolling, is
there any future
plan to change this?

Thanks very much for your comments.

-- 
Best Regards.


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