From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B4CAA3858C39; Fri, 17 Feb 2023 13:20:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4CAA3858C39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676640024; bh=xOkB7bVLWRiQMEMee1qsn+l7HEwxBtUHmB7rg40RJj4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HqqR4rHrDDnKHBzCoFsIf1zhSPDxVy1f2F25YaQiFBaTKy5Ld+Xhd2x3OiYGY5efH OE74j5Hivimt5iquKqR7xHwpzA0aQ4GcmWm9bzPwMxm7u/QbTtoie/qTWbb8w1KW7X VRMNvr+kUFDVCXiHjJ/3h3jhgp5jx9rHE1qqq9Ts= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/108819] [12/13 Regression] ICE on valid code at -O1 with "-fno-tree-ccp -fno-tree-forwprop" on x86_64-linux-gnu: tree check: expected ssa_name, have integer_cst in number_of_iterations_cltz, at tree-ssa-loop-niter.cc:2394 Date: Fri, 17 Feb 2023 13:20:23 +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: 13.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: P2 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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=3D108819 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #3 from Richard Biener --- I have a patch to make niter analysis more defensive, the 1 & 1 is introduc= ed by reassoc: @@ -30,8 +54,8 @@ [local count: 114863530]: _20 =3D a.0_1 =3D=3D 0; _21 =3D a.0_1 > 0; - _22 =3D _20 & _21; - if (_22 !=3D 0) + _7 =3D 1 & 1; + if (_7 !=3D 0) where update_range_test gets a '1' as result and forces that to an SSA name and things go downhill from that. With diff --git a/gcc/tree-ssa-reassoc.cc b/gcc/tree-ssa-reassoc.cc index f163612f140..c2b30a03a9d 100644 --- a/gcc/tree-ssa-reassoc.cc +++ b/gcc/tree-ssa-reassoc.cc @@ -2950,6 +2950,9 @@ update_range_test (struct range_entry *range, struct range_entry *otherrange, } if (stmt =3D=3D NULL) gcc_checking_assert (tem =3D=3D op); + /* When range->exp is a constant, we can use it as-is. */ + else if (is_gimple_min_invariant (tem)) + ; /* In rare cases range->exp can be equal to lhs of stmt. In that case we have to insert after the stmt rather then before it. If stmt is a PHI, insert it at the start of the basic block. */ this is resolved (but we still get the intermediate 1 & 1 created). Jakub, you know this code more(?), can you see whether there's a better place to handle this? I'm testing the niter fortification.=