public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][Modulo-sched] Avoid SMS when the candidate loop contains INC  instruction
@ 2007-07-26 11:06 Revital1 Eres
  2007-07-26 16:40 ` Kenneth Zadeck
  0 siblings, 1 reply; 4+ messages in thread
From: Revital1 Eres @ 2007-07-26 11:06 UTC (permalink / raw)
  To: Ayal Zaks; +Cc: volodyan, abel, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 779 bytes --]


Hello,

We decided to break Patch 1 of 2 into sub-patches and insert them
gradually.  (http://gcc.gnu.org/ml/gcc-patches/2007-07/msg01515.html)

This is the first one which avoids performing SMS when the candidate
loop contains auto-increment instruction.

The testcase attached is inspired from array_constructor_12.f90 testcase.

This patch was bootstrapped and tested on ppc64 with -fmodulo-sched
flag. (all languages except Ada)

:ADDPATCH modulo-sched:

OK for mainline?

Thanks,
Revital

2007-07-26  Vladimir Yanovsky  <yanov@il.ibm.com>

        * modulo-sched.c (sms_schedule): Avoid loops which includes
        auto-increment instructions.

        * testsuite/gfortran.dg/sms-1.f90: New test.


(See attached file: autoinc_patch.txt)(See attached file: sms-1.f90.txt)

[-- Attachment #2: autoinc_patch.txt --]
[-- Type: text/plain, Size: 1391 bytes --]

Index: modulo-sched.c
===================================================================
--- modulo-sched.c	(revision 126552)
+++ modulo-sched.c	(working copy)
@@ -988,12 +988,16 @@
       if ( !(count_reg = doloop_register_get (tail)))
 	continue;
 
-      /* Don't handle BBs with calls or barriers, or !single_set insns.  */
+      /* Don't handle BBs with calls or barriers, or !single_set insns,
+         or auto-increment insns (to avoid creating invalid reg-moves
+         for the auto-increment insns).  
+         ??? Should handle auto-increment insns.  */
       for (insn = head; insn != NEXT_INSN (tail); insn = NEXT_INSN (insn))
 	if (CALL_P (insn)
 	    || BARRIER_P (insn)
 	    || (INSN_P (insn) && !JUMP_P (insn)
-		&& !single_set (insn) && GET_CODE (PATTERN (insn)) != USE))
+		&& !single_set (insn) && GET_CODE (PATTERN (insn)) != USE)
+            || (FIND_REG_INC_NOTE (insn, NULL_RTX) != 0))
 	  break;
 
       if (insn != NEXT_INSN (tail))
@@ -1004,6 +1008,8 @@
 		fprintf (dump_file, "SMS loop-with-call\n");
 	      else if (BARRIER_P (insn))
 		fprintf (dump_file, "SMS loop-with-barrier\n");
+              else if (FIND_REG_INC_NOTE (insn, NULL_RTX) != 0)
+                fprintf (dump_file, "SMS reg inc\n");
 	      else
 		fprintf (dump_file, "SMS loop-with-not-single-set\n");
 	      print_rtl_single (dump_file, insn);

[-- Attachment #3: sms-1.f90.txt --]
[-- Type: text/plain, Size: 708 bytes --]

! { dg-do run }
! { dg-options "-O2 -fmodulo-sched" } 
program main
  integer (kind = 8) :: i, l8, u8, step8
  integer (kind = 4) :: l4, step4
  integer (kind = 8), parameter :: big = 10000000000_8

  u8 = big * 40 + 200
  l4 = 200
  step8 = -big
  call test ((/ (i, i = u8, l4, step8) /), u8, l4 + 0_8, step8)
contains
  subroutine test (a, l, u, step)
    integer (kind = 8), dimension (:), intent (in) :: a
    integer (kind = 8), intent (in) :: l, u, step
    integer (kind = 8) :: i
    integer :: j

    j = 1
    do i = l, u, step
      if (a (j) .ne. i) call abort
      j = j + 1
    end do
    if (size (a, 1) .ne. j - 1) call abort
  end subroutine test
end program main

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH][Modulo-sched] Avoid SMS when the candidate loop contains INC  instruction
  2007-07-26 11:06 [PATCH][Modulo-sched] Avoid SMS when the candidate loop contains INC instruction Revital1 Eres
@ 2007-07-26 16:40 ` Kenneth Zadeck
  2007-07-26 18:21   ` Ayal Zaks
  0 siblings, 1 reply; 4+ messages in thread
From: Kenneth Zadeck @ 2007-07-26 16:40 UTC (permalink / raw)
  To: volodyan, abel, gcc-patches, Ayal Zaks

> Hello,
> 
> We decided to break Patch 1 of 2 into sub-patches and insert them
> gradually.  (http://gcc.gnu.org/ml/gcc-patches/2007-07/msg01515.html)
> 
> This is the first one which avoids performing SMS when the candidate
> loop contains auto-increment instruction.
> 
> The testcase attached is inspired from array_constructor_12.f90 testcase.
> 
> This patch was bootstrapped and tested on ppc64 with -fmodulo-sched
> flag. (all languages except Ada)

This really cannot be the right thing to do.

If you have a loop that you want to modulo schedule, you should expand
the autoinc insn back into two insns.  If you really find some reason
why you do not want to do that, then you should not run the auto inc
finding pass when you enable modulo scheduling.

Kenny

> 
> :ADDPATCH modulo-sched:
> 
> OK for mainline?
> 
> Thanks,
> Revital
> 
> 2007-07-26  Vladimir Yanovsky  <yanov@il.ibm.com>
> 
>         * modulo-sched.c (sms_schedule): Avoid loops which includes
>         auto-increment instructions.
> 
>         * testsuite/gfortran.dg/sms-1.f90: New test.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][Modulo-sched] Avoid SMS when the candidate loop contains INC   instruction
  2007-07-26 16:40 ` Kenneth Zadeck
@ 2007-07-26 18:21   ` Ayal Zaks
  0 siblings, 0 replies; 4+ messages in thread
From: Ayal Zaks @ 2007-07-26 18:21 UTC (permalink / raw)
  To: Kenneth.Zadeck; +Cc: abel, gcc-patches, volodyan

Kenneth Zadeck <Kenneth.Zadeck@NaturalBridge.com> wrote on 26/07/2007
19:22:14:

> > Hello,
> >
> > We decided to break Patch 1 of 2 into sub-patches and insert them
> > gradually.  (http://gcc.gnu.org/ml/gcc-patches/2007-07/msg01515.html)
> >
> > This is the first one which avoids performing SMS when the candidate
> > loop contains auto-increment instruction.
> >
> > The testcase attached is inspired from array_constructor_12.f90
testcase.
> >
> > This patch was bootstrapped and tested on ppc64 with -fmodulo-sched
> > flag. (all languages except Ada)
>
> This really cannot be the right thing to do.
>
> If you have a loop that you want to modulo schedule, you should expand
> the autoinc insn back into two insns.  If you really find some reason
> why you do not want to do that, then you should not run the auto inc
> finding pass when you enable modulo scheduling.
>

Indeed chickening-out in the face of autoinc's is not the right thing to
do.

The current problem that sms has with autoinc insns is that they have
multiple defs.  If one of these defs ends up needing a regmove, we need to
figure out which def it is.  That would be the right thing to do.  An
alternative is to avoid needing regmoves specifically for such multiple
defs.  Currently sms assumes such regmove-needing-defs are the only defs of
their insn, i.e. their lhs.  This is also related to the current
restriction to single_set insns.  There may be another difficulty for sms
with the destructive nature of autoinc insns: sms may want to rename the
address register used (to hook it up to a regmove) without changing the
register defined.

In any case, there are several fixes that address known issues which we'd
like to push through, making forward progress, noting todo/??? items along
the way, and also providing statistics dumps of which restriction are
encountered in practice.

Ayal.


> Kenny
>
> >
> > :ADDPATCH modulo-sched:
> >
> > OK for mainline?
> >
> > Thanks,
> > Revital
> >
> > 2007-07-26  Vladimir Yanovsky  <yanov@il.ibm.com>
> >
> >         * modulo-sched.c (sms_schedule): Avoid loops which includes
> >         auto-increment instructions.
> >
> >         * testsuite/gfortran.dg/sms-1.f90: New test.
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][Modulo-sched] Avoid SMS when the candidate loop contains INC  instruction
       [not found] <OF75BAE848.B63E5DE5-ONC2257323.005B1F08-C2257324.003B7333@LocalDomain>
@ 2007-07-26 11:34 ` Ayal Zaks
  0 siblings, 0 replies; 4+ messages in thread
From: Ayal Zaks @ 2007-07-26 11:34 UTC (permalink / raw)
  To: Revital1 Eres; +Cc: abel, gcc-patches, volodyan

Revital1 Eres/Haifa/IBM wrote on 26/07/2007 13:49:21:

> Hello,
>
> We decided to break Patch 1 of 2 into sub-patches and insert them
> gradually.  (http://gcc.gnu.org/ml/gcc-patches/2007-07/msg01515.html)
>
> This is the first one which avoids performing SMS when the candidate
> loop contains auto-increment instruction.
>
> The testcase attached is inspired from array_constructor_12.f90 testcase.
>
> This patch was bootstrapped and tested on ppc64 with -fmodulo-sched
> flag. (all languages except Ada)
>
> :ADDPATCH modulo-sched:
>
> OK for mainline?
>

OK, if passes on another platform as well.

This is similar to the single_set restriction; we should revisit them both.

Ayal.

> Thanks,
> Revital
>
> 2007-07-26  Vladimir Yanovsky  <yanov@il.ibm.com>
>
>         * modulo-sched.c (sms_schedule): Avoid loops which includes
>         auto-increment instructions.
>
>         * testsuite/gfortran.dg/sms-1.f90: New test.
>
> [attachment "autoinc_patch.txt" deleted by Ayal Zaks/Haifa/IBM]
[attachment
> "sms-1.f90.txt" deleted by Ayal Zaks/Haifa/IBM]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-07-26 17:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-26 11:06 [PATCH][Modulo-sched] Avoid SMS when the candidate loop contains INC instruction Revital1 Eres
2007-07-26 16:40 ` Kenneth Zadeck
2007-07-26 18:21   ` Ayal Zaks
     [not found] <OF75BAE848.B63E5DE5-ONC2257323.005B1F08-C2257324.003B7333@LocalDomain>
2007-07-26 11:34 ` Ayal Zaks

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).