https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128175

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |53947
     Ever confirmed|0                           |1
             Target|                            |x86_64-*-*
             Status|UNCONFIRMED                 |NEW
                 CC|                            |tnfchris at gcc dot gnu.org
   Last reconfirmed|                            |2026-10-26

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue is that the conditional reduction pattern is quite limited:

t.c:9:23: note:   === vect_analyze_scalar_cycles ===
...
t.c:9:23: note:   Analyze phi: p_19 = PHI <p_7(8), 1(18)>
t.c:9:23: missed:   reduction used in loop.
t.c:9:23: missed:   Unknown def-use cycle pattern.

Associating the update like

    for (int i = 0; i < n; i += 1) {
        if (b[i].v != 0) {
            p *= (a[i].v * b[i].v);
        }
    }

vectorizes the loop.

Tamar has done somewhat similar work in ifcvt to enable this in other cases.
Note that to associate we need to perform all multiplications in unsigned
arithmetic because re-associating otherwise might introduce UB.  Just
doing s/int/unsigned/ doesn't on its own fix this.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947
[Bug 53947] [meta-bug] vectorizer missed-optimizations

Reply via email to