public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/113078] New: [14 regression] reduction of cond_sub is not vectorized.
@ 2023-12-19  3:53 liuhongt at gcc dot gnu.org
  2023-12-19  3:59 ` [Bug tree-optimization/113078] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: liuhongt at gcc dot gnu.org @ 2023-12-19  3:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113078
           Summary: [14 regression] reduction of cond_sub is not
                    vectorized.
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: liuhongt at gcc dot gnu.org
  Target Milestone: ---

int
foo (int n, int* p, int* pi)
{
    int sum = 0;
    for (int i = 0; i != n; i++)
    {
        if (pi[i] > 0)
          sum -= p[i];
    }
    return sum;
}

gcc 13 can vectorize it, but latest trunk don't, guess it's related to
optimiztion of COND_OP in ifcvt.

/app/example.cpp:5:23: note:   vect_is_simple_use: vectype vector(8) int
/app/example.cpp:5:23: missed:   reduction: not commutative/associative
/app/example.cpp:2:1: missed:   not vectorized: relevant phi not supported:
sum_18 = PHI <_ifc__32(8), 0(18)>
/app/example.cpp:5:23: missed:  bad operation or unsupported loop bound.

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

* [Bug tree-optimization/113078] [14 regression] reduction of cond_sub is not vectorized.
  2023-12-19  3:53 [Bug tree-optimization/113078] New: [14 regression] reduction of cond_sub is not vectorized liuhongt at gcc dot gnu.org
@ 2023-12-19  3:59 ` pinskia at gcc dot gnu.org
  2023-12-19  9:05 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-19  3:59 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-12-19
             Status|UNCONFIRMED                 |NEW
   Target Milestone|---                         |14.0
     Ever confirmed|0                           |1
             Target|                            |aarch64-linux-gnu
                   |                            |x86_64-linux-gnu

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed on x86_64-linux-gnu with `-O3  -march=skylake-avx512` and
aarch64-linux-gnu with `-O3 -march=armv9-a+sve2` .

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

* [Bug tree-optimization/113078] [14 regression] reduction of cond_sub is not vectorized.
  2023-12-19  3:53 [Bug tree-optimization/113078] New: [14 regression] reduction of cond_sub is not vectorized liuhongt at gcc dot gnu.org
  2023-12-19  3:59 ` [Bug tree-optimization/113078] " pinskia at gcc dot gnu.org
@ 2023-12-19  9:05 ` rguenth at gcc dot gnu.org
  2024-01-10 14:26 ` cvs-commit at gcc dot gnu.org
  2024-01-10 14:27 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-12-19  9:05 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
We special case MINUS_EXPR but likely fail to do the same to COND_SUB in
reduction discovery (vect_is_simple_reduction) and/or vectorizable_reduction.

I will have a look (possibly only next year).

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

* [Bug tree-optimization/113078] [14 regression] reduction of cond_sub is not vectorized.
  2023-12-19  3:53 [Bug tree-optimization/113078] New: [14 regression] reduction of cond_sub is not vectorized liuhongt at gcc dot gnu.org
  2023-12-19  3:59 ` [Bug tree-optimization/113078] " pinskia at gcc dot gnu.org
  2023-12-19  9:05 ` rguenth at gcc dot gnu.org
@ 2024-01-10 14:26 ` cvs-commit at gcc dot gnu.org
  2024-01-10 14:27 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-10 14:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:cac9d2d2346bf06b29b34e12cf0a005c37eacdc9

commit r14-7108-gcac9d2d2346bf06b29b34e12cf0a005c37eacdc9
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Jan 10 14:13:25 2024 +0100

    tree-optimization/113078 - conditional subtraction reduction vectorization

    When if-conversion was changed to use .COND_ADD/SUB for conditional
    reduction it was forgotten to update reduction path handling to
    canonicalize .COND_SUB to .COND_ADD for vectorizable_reduction
    similar to what we do for MINUS_EXPR.  The following adds this
    and testcases exercising this at runtime and looking for the
    appropriate masked subtraction in the vectorized code on x86.

            PR tree-optimization/113078
            * tree-vect-loop.cc (check_reduction_path): Canonicalize
            .COND_SUB to .COND_ADD.

            * gcc.dg/vect/vect-reduc-cond-sub.c: New testcase.
            * gcc.target/i386/vect-pr113078.c: Likewise.

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

* [Bug tree-optimization/113078] [14 regression] reduction of cond_sub is not vectorized.
  2023-12-19  3:53 [Bug tree-optimization/113078] New: [14 regression] reduction of cond_sub is not vectorized liuhongt at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-01-10 14:26 ` cvs-commit at gcc dot gnu.org
@ 2024-01-10 14:27 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-01-10 14:27 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2024-01-10 14:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-19  3:53 [Bug tree-optimization/113078] New: [14 regression] reduction of cond_sub is not vectorized liuhongt at gcc dot gnu.org
2023-12-19  3:59 ` [Bug tree-optimization/113078] " pinskia at gcc dot gnu.org
2023-12-19  9:05 ` rguenth at gcc dot gnu.org
2024-01-10 14:26 ` cvs-commit at gcc dot gnu.org
2024-01-10 14:27 ` 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).