This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/54803] New: Manual constant unfolding breaks vectorization
- From: "jasongross9+bugzilla at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 04 Oct 2012 00:00:21 +0000
- Subject: [Bug c/54803] New: Manual constant unfolding breaks vectorization
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: jasongross9+bugzilla@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.