From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 551193858C66; Thu, 8 Feb 2024 04:28:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 551193858C66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707366519; bh=6VCXhTz+e1dURlBNaCPOFhNf0Ai640vbH6qIdogPs8I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ePCpWG/Lybh6y9rSt8nQYIHrYs37YqI8KIZJOST9cMl8/gk6ylDwFExUfl8FWsymS rtBgmBHwByCQ93YsQx956BdFFVEJjek+Q/ckpO0qBH5hFBW/PbNmti/g+dSseCgGLB FUp2ciR3BuuYLCDHqx4Ggawq+f/spOSXRZtj3sgM= From: "tnfchris at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113808] [14 Regression] FAIL: libgomp.fortran/non-rectangular-loop-1.f90 since r14-8768 Date: Thu, 08 Feb 2024 04:28:38 +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: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: tnfchris at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: tnfchris at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: assigned_to 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=3D113808 Tamar Christina changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |tnfchris at gcc dot= gnu.org --- Comment #9 from Tamar Christina --- (In reply to Richard Biener from comment #6) > With the following I don't see things going wrong, but we end up with the > loop > having the STOP exit last instead and thus a PEELED case. If it's not a PEELED case than the code is wrong indeed. _100 =3D BIT_FIELD_REF ; k.4_43 =3D _100; is wrong since for a normal case the primary exit needs to do a last reduct= ion rather than a first. _109 =3D BIT_FIELD_REF ; _48 =3D _109; _100 =3D BIT_FIELD_REF ; k.4_43 =3D _100; these two reduction orders should never be different. The bug seems to be in vectorizable_live_operations where we determine if t= he index needs to be a first or last reduction. There's a boolean there restart_loop =3D restart_loop || !main_exit_edge; and we initially set it to bool restart_loop =3D LOOP_VINFO_EARLY_BREAKS_VECT_PEELED (loop_vinfo); outside the USE/DEF loop. The problem is this depends on seeing the uses for the LOOP_VINFO_IV_EXIT before seeing that of the early exits. The code goes wrong because we see the early exit first and then see the ma= in exit, but once true the boolean can't become false again. it's a silly bug, the boolean shouldn't be cached between loop iters. quick hack: diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 190df9ec774..109a7e16abb 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -10966,7 +10966,7 @@ vectorizable_live_operation (vec_info *vinfo, stmt_vec_info stmt_info, /* For early exit where the exit is not in the BB that leads to the latch then we're restarting the iteration in the scalar loop. So get the first live value. */ - restart_loop =3D restart_loop || !main_exit_edge; + restart_loop =3D !main_exit_edge; if (restart_loop && STMT_VINFO_DEF_TYPE (stmt_info) =3D=3D vect_induction_= def) { works but will revisit this and fix properly now. Thanks for the reduction.=