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

--- Comment #5 from bin.cheng <amker.cheng at gmail dot com> ---
For the offending loop:

  <bb 5>:

  <bb 6>:
  # b.4_30 = PHI <b.4_12(5), 1(12)>
  # prephitmp_28 = PHI <c.1_9(5), c.1_21(12)>
  # b_lsm.11_13 = PHI <b.4_12(5), 1(12)>
  # ivtmp_46 = PHI <ivtmp_45(5), 13(12)>
  c.1_9 = prephitmp_28 | 1;
  b.4_12 = b.4_30 + 1;
  ivtmp_45 = ivtmp_46 - 1;
  if (ivtmp_45 != 0)
    goto <bb 5>;
  else
    goto <bb 7>;

Now SCEV recognizes b_lsm.11_13 as {1,1}_2, and vectorizer considers it can be
vectorized.
The problem comes in function slpeel_update_phi_nodes_for_guard1 for phi node
:# b_lsm.11_13 = PHI <b.4_12(5), 1(12)>.  It's special because its loop_arg:
b.4_12 has already been handled in previous node and has non-null current
definition, resulting in assertion failure at line:
  gcc_assert (get_current_def (current_new_name) == NULL_TREE);

It seems loop manipulating utility for vectorization can't cope with this kind
PEELED phi node.

We can get more loops vectorized if we can handle this issue in vectorization.
For example, the more complicated example reported can be vectorized
successfully.

But, I think it's a little bit difficult to handle the case because it's
possible to have the PEELED phi node come before the phi node from which it's
peeled from (b.4_30, in this case), just like:

  <bb 5>:

  <bb 6>:
  # b_lsm.11_13 = PHI <b.4_12(5), 1(12)>   <----appear before b.4_30
  # b.4_30 = PHI <b.4_12(5), 1(12)>
  # prephitmp_28 = PHI <c.1_9(5), c.1_21(12)>
  # ivtmp_46 = PHI <ivtmp_45(5), 13(12)>
  c.1_9 = prephitmp_28 | 1;
  b.4_12 = b.4_30 + 1;
  ivtmp_45 = ivtmp_46 - 1;
  if (ivtmp_45 != 0)
    goto <bb 5>;
  else
    goto <bb 7>;

So here I come up three options:
0) handle peeled phi in slpeel_update_phi_nodes_for_guard*.  Maybe two passes
scanning for phi nodes is necessary.
1) reject loops containing peeled phi node in vectorization.
2) add code to rewrite such peeled phi node into normal one.

I am new to vectorization, so any words?

Thanks,
bin

Reply via email to