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



             Bug #: 54803

           Summary: Manual constant unfolding breaks vectorization

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Severity: enhancement

          Priority: P3

         Component: c

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: jasongross9+bugzi...@gmail.com





Created attachment 28348

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28348

code files



Manually unfolding constants sometimes prevents vectorization.



For example, these loops vectorize:



void multi_left_shift0(uint64_t *const array, size_t len, size_t num_bits) {

  for (size_t i = 0; i < len; i++) {

    array[i] = (array[i] >> 31) | (array[i] << 31);

  }

}



void multi_left_shift2(uint64_t *const array, size_t len, size_t num_bits) {

  for (size_t i = 0; i < len; i++) {

    const uint64_t tempa = array[i] >> 32;

    const uint64_t tempb = array[i] << 32;

    array[i] = tempa | tempb;

  }

}





but this loops does not:



void multi_left_shiftb0(uint64_t *const array, size_t len, size_t num_bits) {

  for (size_t i = 0; i < len; i++) {

    array[i] = (array[i] >> 32) | (array[i] << 32);

  }

}





See attached file for the code, preprocessed code, gcc command line log, and

assembly.

Reply via email to