This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/50661] std::equal should use more efficient version for arrays of pointers
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 08 Oct 2011 11:34:51 +0000
- Subject: [Bug libstdc++/50661] std::equal should use more efficient version for arrays of pointers
- Auto-submitted: auto-generated
- References: <bug-50661-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50661
--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-10-08 11:34:51 UTC ---
I guess the problem with autovectorization of loop like:
for (i = 0; i < n; i++)
if (array1[i] != array2[i])
break;
return i == n;
is the control flow in the loop and that the compiler can't know that it is ok
to access array1[i + 1] (assuming i < n) even when array1[i] == array2[i].
One would need to write something like
if (n >= 4)
for (i = 0; i < n - 3; i += 4)
if ((array1[i] != array2[i])
| (array1[i+1] != array2[i+1])
| (array1[i+2] != array2[i+2])
| (array1[i+3] != array2[i+3]))
return 0;
for (; i < n; i++)
if (array1[i] != array2[i])
return 0;
return 1;
to get it SLP vectorized.