This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/69489] New: missed vectorization for boolean loop
- From: "jtaylor.debian at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 26 Jan 2016 14:24:28 +0000
- Subject: [Bug tree-optimization/69489] New: missed vectorization for boolean loop
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69489
Bug ID: 69489
Summary: missed vectorization for boolean loop
Product: gcc
Version: 5.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: jtaylor.debian at googlemail dot com
Target Milestone: ---
following (abbreviated) code does not vectorize with gcc 5.2.1:
gcc file.c -O2 -ftree-vectorize -c
double
yule_bool_distance_char2(const char *u, const char *v, long n)
{
long i;
long ntt = 0, nff = 0, nft = 0, ntf = 0;
for (i = 0; i < n; i++) {
ntf += (u[i] && !v[i]);
nft += (!u[i] && v[i]);
}
return (2.0 * ntf * nft);
}
but if one replaces the loop body with this:
char x = u[i], y = v[i];
ntf += x && (!y);
nft += (!x) && y;
gcc will vectorize it.
As I understand it both code is equivalent, so it would be great if gcc could
vectorize both variants.