public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "fxue at os dot amperecomputing.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/115060] New: Probable an issue around usage of vect_look_through_possible_promotion in tree-vect-patterns.cc
Date: Mon, 13 May 2024 06:24:40 +0000	[thread overview]
Message-ID: <bug-115060-4@http.gcc.gnu.org/bugzilla/> (raw)

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?
    {
      ...
    }

             reply	other threads:[~2024-05-13  6:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-13  6:24 fxue at os dot amperecomputing.com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-115060-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).