public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/114193] New: missed early break vectorization of reduction
@ 2024-03-01 17:01 acoplan at gcc dot gnu.org
  2024-03-04  9:19 ` [Bug tree-optimization/114193] " rguenth at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: acoplan at gcc dot gnu.org @ 2024-03-01 17:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114193
           Summary: missed early break vectorization of reduction
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: acoplan at gcc dot gnu.org
  Target Milestone: ---

For the following loop:

int a[1024];
int f(int *x, int n)
{
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] == 42)
            break;
        sum += a[i];
    }
    return sum;
}

at -O3 on aarch64 we miss vectorizing it.  It works if I move the early exit
down below the update of sum.  It looks like vect_analyze_scalar_cycles fails
to detect this as a reduction:

/app/example.c:5:23: note:   Analyze phi: sum_10 = PHI <sum_6(7), 0(6)>
/app/example.c:5:23: missed:   intermediate value used outside loop.
/app/example.c:5:23: missed:   Unknown def-use cycle pattern.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug tree-optimization/114193] missed early break vectorization of reduction
  2024-03-01 17:01 [Bug tree-optimization/114193] New: missed early break vectorization of reduction acoplan at gcc dot gnu.org
@ 2024-03-04  9:19 ` rguenth at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-03-04  9:19 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2024-03-04
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  We can relax this (but constrained to the PHI def intermediate use)
for uses on early exit edges.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-04  9:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-01 17:01 [Bug tree-optimization/114193] New: missed early break vectorization of reduction acoplan at gcc dot gnu.org
2024-03-04  9:19 ` [Bug tree-optimization/114193] " rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).