Vectorisation of loop does not work with different variable names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello @ all,

I successfully vectorized a simple loop:
```
bool func_is_vectorized (char*& cur, context& ctx)  {

    match_return r {cur, true};
    constexpr char str1[] =
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; 
    if (!(std::distance(r.pos, ctx.end) < 50)) {return false;}

    for(int i = 0; i < 50; i += 1) {
        if (str1[i] != r.pos[i]) { r.matched = false; }
    }
    if (r.matched) {
        r.pos += 50;
    }
    return r.matched;
    
}
```

I wanted to remove the match_return structure and now the loop no
longer vectorizes. The message is: 
not vectorized: relevant phi not supported: matched_21 = PHI <_20(6),
1(5)>

The "new" code is:
```
bool func_is_also_not_vectorized (char*& cur, context& ctx)  {

    bool matched = true;
    constexpr char str1[] =
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; 
    if (!(std::distance(cur, ctx.end) < 50)) {return false;}

    for(int i = 0; i < 50; i += 1) {
        if (str1[i] != cur[i]) { matched = false; }
    }
    if (matched) {
        cur += 50;
    }
    return matched;  
}
```

The interesting part is. If I only replace `r.matched` with `matched`
and introduce the proper variable. The vectorizer is already failing.

A reproducer on compiler explorer: https://godbolt.org/z/YEPzfx3eT

Am I doing something wrong? Is this a possible bug?

Cheers

Max 

Attachment: smime.p7s
Description: S/MIME cryptographic signature


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux