Avoid SMS when the candidate loop contains INC instruction
authorVladimir Yanovsky <yanov@il.ibm.com>
Sat, 28 Jul 2007 21:51:53 +0000 (21:51 +0000)
committerRevital Eres <revitale@gcc.gnu.org>
Sat, 28 Jul 2007 21:51:53 +0000 (21:51 +0000)
Co-Authored-By: Revital Eres <eres@il.ibm.com>
From-SVN: r127027

gcc/ChangeLog
gcc/modulo-sched.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/sms-1.f90 [new file with mode: 0644]

index 47af5547893eea26180a4e5fce496f1de1b9e808..c8468a17642d377495a7808bc7020d3ebf5a841e 100644 (file)
@@ -1,3 +1,9 @@
+2007-07-29  Vladimir Yanovsky  <yanov@il.ibm.com>
+            Revital Eres  <eres@il.ibm.com>
+
+       * modulo-sched.c (sms_schedule): Avoid loops which includes
+       auto-increment instructions.
+
 2007-07-28  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/32920
index d543e6bdaf0ce723523e42d8dd69e3dcfbc90f78..16cd5d88e24aae335dfe469f9c4c048657f210de 100644 (file)
@@ -987,12 +987,16 @@ sms_schedule (void)
       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))
@@ -1003,6 +1007,8 @@ sms_schedule (void)
                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);
index 7c4fd7d0a66317faf2ea7d9fe437857acb32d636..4bf697bcde6a28ec8a69c1959c91df124172284c 100644 (file)
@@ -1,3 +1,8 @@
+2007-07-29  Vladimir Yanovsky  <yanov@il.ibm.com>
+            Revital Eres  <eres@il.ibm.com>
+
+       * gfortran.dg/sms-1.f90: New test.
+
 2007-07-28  Richard Guenther  <rguenther@suse.de>
 
        * gcc.c-torture/compile/pr32920.c: New testcase.
diff --git a/gcc/testsuite/gfortran.dg/sms-1.f90 b/gcc/testsuite/gfortran.dg/sms-1.f90
new file mode 100644 (file)
index 0000000..f9bfafe
--- /dev/null
@@ -0,0 +1,28 @@
+! { 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
+
+