public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/115060] New: Probable an issue around usage of vect_look_through_possible_promotion in tree-vect-patterns.cc
@ 2024-05-13  6:24 fxue at os dot amperecomputing.com
  2024-05-13 10:21 ` [Bug tree-optimization/115060] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: fxue at os dot amperecomputing.com @ 2024-05-13  6:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115060
           Summary: Probable an issue around usage of
                    vect_look_through_possible_promotion in
                    tree-vect-patterns.cc
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fxue at os dot amperecomputing.com
  Target Milestone: ---

The purpose of the function is to peel off type casts to find out root
definition for a given value. If patterns are involved, intermediate
pattern-defined SSAs would be traversed instead of the originals. A subtlety
here is that the root SSA (as the return value) might be the original one, even
it has been recognized as a pattern. For example,

   a = (T1) patt_b;
   patt_b = (T2) c;        // b = ...
   patt_c = not-a-cast;    // c = old_seq

Given 'a', the function will return 'c', instead of 'patt_c'. If a caller only
does something based on type information of returned SSA, there is no problem.
But if caller's pattern recog analysis is to parse definition statement of the
SSA, the new pattern statement is bypassed. This tends to be inconsistent with
processing logic of the pattern formation pass, which is not quite rational,
and seems to be an issue, though does not cause any mistake. Anything that I
missed here?

Take one code snippet as example:

vect_recog_mulhs_pattern ()
{
  ...

  vect_unpromoted_value unprom_rshift_input;
  tree rshift_input = vect_look_through_possible_promotion
    (vinfo, gimple_assign_rhs1 (last_stmt), &unprom_rshift_input);

  ...

  /* Get the definition of the shift input.  */
  stmt_vec_info rshift_input_stmt_info
    = vect_get_internal_def (vinfo, rshift_input);
  if (!rshift_input_stmt_info)
    return NULL;
  gassign *rshift_input_stmt
    = dyn_cast <gassign *> (rshift_input_stmt_info->stmt);
  if (!rshift_input_stmt)
    return NULL;

   ...

  if (gimple_assign_rhs_code (rshift_input_stmt) == PLUS_EXPR)  // How about if
rshift_input_stmt has a pattern replacement?
    {
      ...
    }

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

* [Bug tree-optimization/115060] Probable an issue around usage of vect_look_through_possible_promotion in tree-vect-patterns.cc
  2024-05-13  6:24 [Bug tree-optimization/115060] New: Probable an issue around usage of vect_look_through_possible_promotion in tree-vect-patterns.cc fxue at os dot amperecomputing.com
@ 2024-05-13 10:21 ` rguenth at gcc dot gnu.org
  2024-05-28 14:02 ` cvs-commit at gcc dot gnu.org
  2024-06-02  1:41 ` fxue at os dot amperecomputing.com
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-13 10:21 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
                 CC|                            |rguenth at gcc dot gnu.org,
                   |                            |rsandifo at gcc dot gnu.org
   Last reconfirmed|                            |2024-05-13
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  Probably vect_get_internal_def itself should concern itself with
this.

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

* [Bug tree-optimization/115060] Probable an issue around usage of vect_look_through_possible_promotion in tree-vect-patterns.cc
  2024-05-13  6:24 [Bug tree-optimization/115060] New: Probable an issue around usage of vect_look_through_possible_promotion in tree-vect-patterns.cc fxue at os dot amperecomputing.com
  2024-05-13 10:21 ` [Bug tree-optimization/115060] " rguenth at gcc dot gnu.org
@ 2024-05-28 14:02 ` cvs-commit at gcc dot gnu.org
  2024-06-02  1:41 ` fxue at os dot amperecomputing.com
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-28 14:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Feng Xue <fxue@gcc.gnu.org>:

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

commit r15-863-ga3aeff4ce95bd616a2108dc2363d9cbaba53b170
Author: Feng Xue <fxue@os.amperecomputing.com>
Date:   Thu May 23 15:25:53 2024 +0800

    vect: Use vect representative statement instead of original in patch recog
[PR115060]

    Some utility functions (such as vect_look_through_possible_promotion) that
are
    to find out certain kind of direct or indirect definition SSA for a value,
may
    return the original one of the SSA, not its pattern representative SSA,
even
    pattern is involved. For example,

       a = (T1) patt_b;
       patt_b = (T2) c;        // b = ...
       patt_c = not-a-cast;    // c = ...

    Given 'a', the mentioned function will return 'c', instead of 'patt_c'.
This
    subtlety would make some pattern recog code that is unaware of it mis-use
the
    original instead of the new pattern statement, which is inconsistent wth
    processing logic of the pattern formation pass. This patch corrects the
issue
    by forcing another utility function (vect_get_internal_def) return the
pattern
    statement information to caller by default.

    2024-05-23 Feng Xue <fxue@os.amperecomputing.com>

    gcc/
            PR tree-optimization/115060
            * tree-vect-patterns.cc (vect_get_internal_def): Return statement
for
            vectorization.
            (vect_widened_op_tree): Call vect_get_internal_def instead of
look_def
            to get statement information.
            (vect_recog_widen_abd_pattern): No need to call
vect_stmt_to_vectorize.

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

* [Bug tree-optimization/115060] Probable an issue around usage of vect_look_through_possible_promotion in tree-vect-patterns.cc
  2024-05-13  6:24 [Bug tree-optimization/115060] New: Probable an issue around usage of vect_look_through_possible_promotion in tree-vect-patterns.cc fxue at os dot amperecomputing.com
  2024-05-13 10:21 ` [Bug tree-optimization/115060] " rguenth at gcc dot gnu.org
  2024-05-28 14:02 ` cvs-commit at gcc dot gnu.org
@ 2024-06-02  1:41 ` fxue at os dot amperecomputing.com
  2 siblings, 0 replies; 4+ messages in thread
From: fxue at os dot amperecomputing.com @ 2024-06-02  1:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Feng Xue <fxue at os dot amperecomputing.com> ---
Linaro reported a regression:
https://linaro.atlassian.net/browse/GNU-1226

Actually, this is not, but exposes a new bug in
vect_look_through_possible_promotion. The function fails to figure out root
definition if casts involves more than two promotions with sign change as:

long a = (long)b;       // promotion cast
 -> int b = (int)c;     // promotion cast, sign change
   -> unsigned short c = ...;

For this case, the function thinks the 2nd cast has different sign as the 1st,
so stop looking through, while "unsigned short -> integer" is a nature sign
extension.

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

end of thread, other threads:[~2024-06-02  1:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-13  6:24 [Bug tree-optimization/115060] New: Probable an issue around usage of vect_look_through_possible_promotion in tree-vect-patterns.cc fxue at os dot amperecomputing.com
2024-05-13 10:21 ` [Bug tree-optimization/115060] " rguenth at gcc dot gnu.org
2024-05-28 14:02 ` cvs-commit at gcc dot gnu.org
2024-06-02  1:41 ` fxue at os dot amperecomputing.com

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).