This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/69489] New: missed vectorization for boolean loop


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]