public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/107082] New: Fix incorrect handle in vectorizable_induction for mixed induction type
@ 2022-09-29  7:22 crazylht at gmail dot com
  0 siblings, 0 replies; only message in thread
From: crazylht at gmail dot com @ 2022-09-29  7:22 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107082
           Summary: Fix incorrect handle in vectorizable_induction for
                    mixed induction type
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
  Target Milestone: ---

The codes in vectorizable_induction for slp_node assume all phi_info
have same induction type(vect_step_op_add), but since we support
nonlinear induction, it could be wrong handled.

https://gcc.gnu.org/pipermail/gcc-patches/2022-September/601913.html

----------Comments from Richard-------
While it works to check this here the canonical place to match up def
types is in
vect_get_and_check_slp_defs.  There we do

      /* Not first stmt of the group, check that the def-stmt/s match
         the def-stmt/s of the first stmt.  Allow different definition
         types for reduction chains: the first stmt must be a
         vect_reduction_def (a phi node), and the rest
         end in the reduction chain.  */
      if ((!vect_def_types_match (oprnd_info->first_dt, dt)
           && !(oprnd_info->first_dt == vect_reduction_def
                && !STMT_VINFO_DATA_REF (stmt_info)

the induction def type match now needs to also compare
STMT_VINFO_LOOP_PHI_EVOLUTION_TYPE
it seems.

Note we also fail to do this for STMT_VINFO_REDUC_TYPE (but that's eventually
only computed too late).

Being able to reject this during SLP discovery means that if you'd have

   x = i + j;
   y = j + i;

with two different induction types for 'i' and 'j', SLP discovery can
try commutative
swapping to match the inductions up for x and y and successfully SLP
the operation.

That said, I can see the checking condition becoming more ugly (please don't
try to amend vect_def_types_match itself), adding something like

    || (oprnd_info->first_dt == vect_induction_def
        && STMT_VINFO_LOOP_PHI_EVOLUTION_TYPE (...) != ... (stmts[0]))

Can you try doing that?
-----comments end--------


Open this PR to track this.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-29  7:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-29  7:22 [Bug tree-optimization/107082] New: Fix incorrect handle in vectorizable_induction for mixed induction type crazylht at gmail dot 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).