From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C21703858C78; Mon, 8 Jan 2024 10:25:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C21703858C78 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704709509; bh=sZ1KTLTJ7rMNtPqBSQ9OxbR823qikn0OWw8fDlgVY84=; h=From:To:Subject:Date:In-Reply-To:References:From; b=E2mp8RneT58mBCwPoVz/uhB/mfcaMLLtAf7eg9rJrsCtbV73pjNf5pxVY4m9jkWpx DALXQRzUwRWZzAHrsXztpgetX9i5E1pqDCL8ZLU251uvEzyqs8DTaPbiYGXkLhgmG3 LQPYcXqgExXHyHCGcomdL9ecM40tNJRIba2nSLeY= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113210] [14 Regression] ICE: tree check: expected integer_cst, have cond_expr in get_len, at tree.h:6481 Date: Mon, 08 Jan 2024 10:25:08 +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: ice-on-valid-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: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113210 --- Comment #14 from Richard Biener --- (In reply to Richard Biener from comment #13) > (In reply to Richard Biener from comment #12) > > (In reply to Jakub Jelinek from comment #11) > > > (In reply to Richard Biener from comment #9) > > > > That is, another fix might be to adjust NITERSM1 to NITERS - 1 when > > > > NITERS went constant ... (btw, I want to get rid of _NITERS and on= ly > > >=20 > > > Or we could only use fold_build2 for the PLUS_EXPR 1 computation if N= ITERSM1 > > > is INTEGER_CST, otherwise use build2... > >=20 > > I think we should see where the original expression is built but not fo= lded. >=20 > Hmm, probably in estimate_numbers_of_iterations, >=20 > if (TREE_CODE (niter_desc.may_be_zero) !=3D INTEGER_CST) > niter =3D build3 (COND_EXPR, type, niter_desc.may_be_zero, > build_int_cst (type, 0), > niter); >=20 > I vaguely remember code trying to pattern match the COND_EXPR created > by this (though it should instead use number_of_iterations_exit). It > should be safe to replace the above with fold_build3. No, it's not that. The COND_EXPR is folded, but we see (short unsigned int) (a.0_1 + 255) + 1 > 256 ? ~(short unsigned int) (a.0_1= + 255) : 0 and that isn't catched. #0 0x00000000014d3464 in fold_build3_loc (loc=3D0, code=3DCOND_EXPR,=20 type=3D,=20 op0=3D, op1=3D,=20 op2=3D) at /space/rguenther/src/gcc/gcc/fold-const.cc:14174 #1 0x00000000014d0513 in fold_ternary_loc (loc=3D0, code=3DCOND_EXPR,=20 type=3D,=20 op0=3D, op1=3D,=20 op2=3D) at /space/rguenther/src/gcc/gcc/fold-const.cc:13238 #2 0x00000000014d3436 in fold_build3_loc (loc=3D0, code=3DCOND_EXPR,=20 type=3D,=20 op0=3D, op1=3D,=20 op2=3D) at /space/rguenther/src/gcc/gcc/fold-const.cc:14172 #3 0x0000000001d4de50 in vect_get_loop_niters (loop=3D0x7ffff71e3600,=20 main_exit=3D0x7ffff7203990, assumptions=3D0x7fffffffd200,=20 number_of_iterations=3D0x7fffffffd1f0, number_of_iterationsm1=3D0x7ffff= fffd1f8) at /space/rguenther/src/gcc/gcc/tree-vect-loop.cc:919 So I suggest to either try fixing that or, when adding one folds to a const= ant make sure M1 is constant as well.=