From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6651A3857407; Fri, 27 Aug 2021 13:27:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6651A3857407 From: "guojiufu at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102087] [12 Regression] ICE on valid code at -O3 on x86_64-linux-gnu: in determine_exit_conditions, at tree-ssa-loop-manip.c:1049 since r12-3136-g3673dcf6d6baeb67 Date: Fri, 27 Aug 2021 13:27: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: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: guojiufu at gcc dot gnu.org X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 13:27:38 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102087 --- Comment #6 from Jiu Fu Guo --- Drafting patch to calculate three items: control, bound and cmp. ---- diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 7af92d1c893..c6e4b24fd83 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -1482,7 +1482,7 @@ number_of_iterations_until_wrap (class loop *, tree t= ype, affine_iv *iv0, affine_iv *iv1, class tree_niter_desc *nit= er) { tree niter_type =3D unsigned_type_for (type); - tree step, num, assumptions, may_be_zero; + tree step, num, assumptions, may_be_zero, span; wide_int high, low, max, min; may_be_zero =3D fold_build2 (LE_EXPR, boolean_type_node, iv1->base, iv0->base); @@ -1513,6 +1513,8 @@ number_of_iterations_until_wrap (class loop *, tree t= ype, affine_iv *iv0, low =3D wi::to_wide (iv0->base); else low =3D min; + + niter->control =3D *iv1; } /* {base, -C} < n. */ else if (tree_int_cst_sign_bit (iv0->step) && integer_zerop (iv1->step)) @@ -1533,6 +1535,8 @@ number_of_iterations_until_wrap (class loop *, tree t= ype, affine_iv *iv0, high =3D wi::to_wide (iv1->base); else high =3D max; + + niter->control =3D *iv0; } else return false; @@ -1556,6 +1560,14 @@ number_of_iterations_until_wrap (class loop *, tree type, affine_iv *iv0, niter->assumptions, assumptions); niter->control.no_overflow =3D false; + tree niter_m1 =3D fold_build2 (MINUS_EXPR, niter_type, niter->niter, + build_int_cst (niter_type, 1)); + span =3D fold_build2 (MULT_EXPR, niter_type, niter_m1, + fold_convert (niter_type, niter->control.step)); + niter->bound =3D fold_build2 (PLUS_EXPR, niter_type, span, + fold_convert (niter_type, niter->control.base= )); + niter->bound =3D fold_convert (type, niter->bound); + niter->cmp =3D NE_EXPR; return true; } ------------------------ While this code may generate complicated niter->bound if the step is not +-= 1.=