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]

[PATCH] Implementing Swing Modulo Scheduling in GCC


This patch includes the initial version of the modulo scheduler
(following http://gcc.gnu.org/ml/gcc/2004-02/msg00071.html).
It is implemented as a separate phase immediately preceding the
first schedule_insn pass, and is activated by -fmodulo-sched flag
(it is inactive by default).

The simple example

  float dot (float* a, float* b, int n)
  {
    int i;
    float result = 0;

    for (i=0; i<7; i++)
      result += a[i]*b[i];

    return result;
  }

is modulo-scheduled (on powerpc-apple-darwin6.4 with -O3 -fmodulo-sched)
into:

_dot:
        mflr r6
        stw r31,-8(r1)
        li r2,0
        li r0,6         /* adjusting loop count */
        bcl 20,31,"L00000000001$pb"
"L00000000001$pb":
        mtctr r0
        slwi r5,r2,2
        addi r2,r2,1
        mflr r31
        stw r6,16(r1)
        lfsx f13,r5,r3  /* prolog */
        lfsx f0,r5,r4   /* prolog */
        addis r9,r31,ha16(LC0-"L00000000001$pb")
        lfs f1,lo16(LC0-"L00000000001$pb")(r9)
L8:
        slwi r7,r2,2
        fmadds f1,f13,f0,f1
        addi r2,r2,1
        lfsx f13,r7,r3
        lfsx f0,r7,r4
        bdnz L8
        lwz r3,16(r1)
        fmadds f1,f13,f0,f1  /* epilog */
        lwz r31,-8(r1)
        mtlr r3
        blr

The following patch was regression tested and bootstrapped on
powerpc-apple-darwin7.2.0 platform.

Ok for mainline?

2004-03-12  Ayal Zaks  <zaks@il.ibm.com>
      Mostafa Hagog  <mustafa@il.ibm.com>

      * Makefile.in: New files modulo-sched.o, ddg.o.
      * ddg.h: New file with interface of a Data Dependence Graph
      for simple loops.
      * ddg.c: New file with implementation of a Data Dependence Graph
      for simple loops.
      * modulo-sched.c: New file with implementation of SMS modulo
      scheduler.
      * cfglayout.c (duplicate_insn_chain): Remove "static" and push
      internals out to a separate new "dupicate_insn" function.
      (duplicate_insn): New function - the internals of the above.
      * common.opt (fmodulo-sched): New flag for activating modulo
scheduling.
      * flags.h (flag_modulo_sched): Same as above.
      * opts.c (flag_modulo_sched): Set to be default.
      * params.def (max-sms-loop-number): New flag limiting the modulo
      scheduler to a given number of loops, for debugging.
      (sms-max-ii-factor): New flag, for tuning when to quit modulo
scheduling.
      * params.h (MAX-SMS-LOOP-NUMBER): Same as above.
      (SMS-MAX-II-FACTOR): Same as above.
      * toplev.c: Add a phase calling sms_schedule, with -dm for dumps.
      * docs/invoke.texi: Document the new -fmodulo-sched option.

Ayal Zaks & Mostafa Hagog

(See attached file: sms-opts-c.patch)(See attached file: ddg.c)(See
attached file: ddg.h)(See attached file: modulo-sched.c)(See attached file:
sms.patch)

Attachment: sms-opts-c.patch
Description: Binary data

Attachment: ddg.c
Description: Binary data

Attachment: ddg.h
Description: Binary data

Attachment: modulo-sched.c
Description: Binary data

Attachment: sms.patch
Description: Binary data


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