From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7FB213858C20; Tue, 11 Oct 2022 09:30:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7FB213858C20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665480632; bh=f1VjlK9p1VrVpesFkfLYPLL5BCRhNqZoh3zEdvJ5tPY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=YHO0UhMS1zFi1WHhCBwAM3IOAVVKH768iAIlNwJBCfbQJOhqlOvaeM3ei4Z80V5b0 KZCgyHAjORAHcuNJPH9hTJHLcWZq85Fglc8qZYC/eLZWGTouVEIqjBD5Vp/oNnT6oU PN3z85Q4zop+eTn3HjPAo9iLwlYl03vnA3zmpWzU= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107212] [11/12/13 Regression] Wrong vectorizer code since r11-718-gc735929a2503a7d0 Date: Tue, 11 Oct 2022 09:30:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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=3D107212 --- Comment #4 from Richard Biener --- So the speciality here is that with the SLP reduction we have the live lanes split across the sum and the convert. That wrecks havoc with vectorizable_reduction following one of the lanes in the loop assigning STMT_VINFO_REDUC_DEF to the reduction chain. We simply do /* ??? For epilogue generation live members of the chain need to point back to the PHI via their original stmt for info_for_reduction to work. */ if (STMT_VINFO_LIVE_P (vdef)) STMT_VINFO_REDUC_DEF (def) =3D phi_info; but in this case this misses one of the paths. Also we're not reliably following the representative here. Plus vectorizable_live_operation doesn't get the representative but the actual scalar stmt defining the live lane (on purpose). So the fix is to make sure the above setting of STMT_VINFO_REDUC_DEF covers all live lanes of the SLP node. For vectorizable_live_operation the else /* For SLP reductions the meta-info is attached to the representative. */ stmt_info =3D SLP_TREE_REPRESENTATIVE (slp_node); doing is then wrong and /* For SLP reductions we vectorize the epilogue for all involved stmts together. */ else if (slp_index !=3D 0) return true; is also suspicious then but it seems we cope with the conversions just fine. So we're actually vectorizing the epilogue for the live lane 0 in the reduction chain but analysis might end up not following the lane 0 SSA use-def chain and identifying lane > 0 reductions is just to avoid non-reduction live code gen.=