From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2B5EC3858C83; Thu, 29 Sep 2022 07:22:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2B5EC3858C83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664436157; bh=N8PDUfbbYivJwDtYCtVJ/b+pFrWHPEQRvMtOYi4satI=; h=From:To:Subject:Date:From; b=fEyvQ3xBRCufQ8XZldfHGyjX4D0hI8VgIRFPEdvQhJIbIngP8va2NQez6cMbKkVCn Xxs+wHWaZntN0JTHYi5rLSQOV7Ckaj2UNl8EyK3DHkZiga0FwXeVILTh9kf1EE1dIN R3aRjEzufUdbBgu/StNBXUP+jvPdZCMuwsnUAI8Y= From: "crazylht at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107082] New: Fix incorrect handle in vectorizable_induction for mixed induction type Date: Thu, 29 Sep 2022 07:22:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: crazylht at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107082 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 =3D=3D 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 eventual= ly only computed too late). Being able to reject this during SLP discovery means that if you'd have x =3D i + j; y =3D 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 =3D=3D vect_induction_def && STMT_VINFO_LOOP_PHI_EVOLUTION_TYPE (...) !=3D ... (stmts[0])) Can you try doing that? -----comments end-------- Open this PR to track this.=