[Bug c/105363] -ftree-slp-vectorize decreases performance significantly (x64)

crazylht at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Apr 25 03:16:28 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105363

Hongtao.liu <crazylht at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |crazylht at gmail dot com

--- Comment #1 from Hongtao.liu <crazylht at gmail dot com> ---
STLF issues here.
 Performance counter stats for './12.out':

     1,248,728,604      ld_blocks.store_forward:u

       5.756169101 seconds time elapsed

       5.746946000 seconds user
       0.001999000 seconds sys


and this case doens't need IPA, it's SLP inside the loop which has
cross-iteration data-dependence, I think we need to prevent that.

#define N 50000
int a[N];

void insertionsort(int a[], int n)
{
  int i, j;

  for (i = 1; i < n; i++) {
    for (j = i-1; j >= 0 && a[j] > a[j+1]; j--) {
      int t  = a[j+1];
      a[j+1] = a[j];
      a[j]   = t;
    }
  }
}

dump:

  <bb 5> [local count: 958878294]:
  MEM <vector(2) int> [(int *)_37] = vect__4.9_45;
  ivtmp.17_47 = ivtmp.17_28 + 18446744073709551612;
  if (_11 != ivtmp.17_47)
    goto <bb 7>; [94.50%]
  else
    goto <bb 6>; [5.50%]

  <bb 6> [local count: 114863531]:
  ivtmp.25_50 = ivtmp.25_9 + 1;
  ivtmp.28_52 = ivtmp.28_51 + 4;
  if (ivtmp.25_50 != _59)
    goto <bb 4>; [89.00%]
  else
    goto <bb 8>; [11.00%]

  <bb 7> [local count: 1014686024]:
  # ivtmp.17_28 = PHI <ivtmp.17_47(5), _61(4)>
  _37 = (void *) ivtmp.17_28;
  vect__8.8_46 = MEM <vector(2) int> [(int *)_37];
  vect__4.9_45 = VEC_PERM_EXPR <vect__8.8_46, vect__8.8_46, { 1, 0 }>;
  _43 = BIT_FIELD_REF <vect__8.8_46, 32, 0>;
  _44 = BIT_FIELD_REF <vect__8.8_46, 32, 32>;
  if (_43 > _44)
    goto <bb 5>; [94.50%]
  else
    goto <bb 6>; [5.50%]

  <bb 8> [local count: 14196616]:


More information about the Gcc-bugs mailing list