Consider the following testcase compiled on SPU, r130287:

#define M 1000

void
foo (int *X, int *Y, int size, int n)
{
  int i, j;
  int acum;

  for (i = 0; i < M; i++)
    {
      acum = 0;
      for (j = 0; j < n; j++)
        {
          acum += (X[j] * X[j + i]);
        }

      Y[i] = acum;
    }
}

The following is the description of the problem, taken from SMS wiki page
http://gcc.gnu.org/wiki/SwingModuloScheduling:
SMS currently works only on single-basic-block loops. There are cases in which
out-of-SSA inserts a copy stmt on the back-edge, resulting in a non-empty latch
block. This usually happens to vectorized loops that have misaligned accesses
(in which we use the value loaded in the previous iteration, combined with the
value loaded in the current iteration, and extract the desired elements from
these two vectors). 

So, the vectorized loop in this example is not SMSed because of the non-empty
latch while the scalar version of the loop is SMSed.

[taken from the sms dump file, here is the details of the vectorized loop:]

;; Loop 2
;;  header 4, latch 3
;;  depth 2, outer 1
;;  nodes: 4 3

...

the latch of the loop contains the following:
;; Pred edge  4 [50.0%]
(code_label 93 374 76 3 3 "" [1 uses])

(note 76 93 77 3 [bb 3] NOTE_INSN_BASIC_BLOCK)

(insn 77 76 78 3 y.c:5 (set (reg:V4SI 215 [ vect_var_.35 ])
        (reg:V4SI 203 [ vect_var_.100 ])) 7 {_movv4si} (expr_list:REG_DEAD
(reg:V4SI 203 [ vect_var_.100 ])
        (nil)))

(insn 78 77 180 3 y.c:5 (set (reg:V4SI 212 [ vect_var_.56 ])
        (reg:V4SI 202 [ vect_var_.101 ])) 7 {_movv4si} (expr_list:REG_DEAD
(reg:V4SI 202 [ vect_var_.101 ])
        (nil)))
;; End of basic block 3 -> ( 4)


-- 
           Summary: missed optimization: cleanup loop latch (SMS)
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: eres at il dot ibm dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34263

Reply via email to