From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CFE48386CE5C; Thu, 30 Jun 2022 03:34:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CFE48386CE5C From: "luoxhu at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106126] [12 Regression] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 since r13-1184-g57424087e82db140 Date: Thu, 30 Jun 2022 03:34:51 +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: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: luoxhu at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: marxin at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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: Thu, 30 Jun 2022 03:34:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106126 --- Comment #13 from luoxhu at gcc dot gnu.org --- Otherwise we need record first_bb when conditions_in_bbs->is_empty, then ch= eck that in is_beneficial, ordered_remove the info entry if that bb is not the first "if condition" with side_effect statement in it, the fix would be as below, but I am not sure whether it is worth&correct way doing this to hand= le both PR105740 and PR106126? git diff diff --git a/gcc/gimple-if-to-switch.cc b/gcc/gimple-if-to-switch.cc index f7b0b02628b..44bb0228856 100644 --- a/gcc/gimple-if-to-switch.cc +++ b/gcc/gimple-if-to-switch.cc @@ -63,7 +63,7 @@ struct condition_info condition_info (gcond *cond): m_cond (cond), m_bb (gimple_bb (cond)), m_forwarder_bb (NULL), m_ranges (), m_true_edge (NULL), m_false_edge (NULL), - m_true_edge_phi_mapping (), m_false_edge_phi_mapping () + m_true_edge_phi_mapping (), m_false_edge_phi_mapping (), first_bb(fals= e) { m_ranges.create (0); } @@ -80,6 +80,7 @@ struct condition_info edge m_false_edge; mapping_vec m_true_edge_phi_mapping; mapping_vec m_false_edge_phi_mapping; + bool first_bb; }; /* Recond PHI mapping for an original edge E and save these into vector VE= C.=20 */ @@ -194,6 +195,16 @@ if_chain::is_beneficial () auto_vec clusters; clusters.create (m_entries.length ()); + for (unsigned i =3D 0; i < m_entries.length (); i++) + { + condition_info *info =3D m_entries[i]; + if (info->first_bb && i !=3D 0 && !no_side_effect_bb (info->m_bb)) + { + m_entries.ordered_remove (i); + break; + } + } + for (unsigned i =3D 0; i < m_entries.length (); i++) { condition_info *info =3D m_entries[i]; @@ -397,6 +408,8 @@ find_conditions (basic_block bb, tree_code code =3D gimple_cond_code (cond); condition_info *info =3D new condition_info (cond); + if (conditions_in_bbs->is_empty ()) + info->first_bb =3D true;=