From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 498153858C24; Fri, 5 Apr 2024 15:36:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 498153858C24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712331363; bh=kSKAlsUFsmkUS3Z+jMvamphGteuGZbDfLLMVcTLUSHw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LOqo3BqI5OFeU6lIjxujRj4fpV4D9hm5HVDsaj8e+bfE6pSBdnXbG0dQS7SvWXR0a swNrkEe13TRjcolADvxyU63ff5WfJMexJIeMUrlO6bZXvkDqFsdoDfqjQgVP+Ny3UW vzqOUT8tYuepRKzmnGVwohHMkLQ3cwwujgANQpJo= From: "amonakov at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114480] g++: internal compiler error: Segmentation fault signal terminated program cc1plus Date: Fri, 05 Apr 2024 15:35:59 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.4.0 X-Bugzilla-Keywords: compile-time-hog, memory-hog, ra X-Bugzilla-Severity: normal X-Bugzilla-Who: amonakov at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114480 --- Comment #21 from Alexander Monakov --- It is possible to reduce gcc_qsort workload by improving the presorted-ness= of the array, but of course avoiding quadratic behavior would be much better. With the following change, we go from 261,250,628,954 cycles:u 533,040,964,437 instructions:u # 2.04 insn per cycle 114,415,857,214 branches:u 395,327,966 branch-misses:u # 0.35% of all branches to 256,620,517,403 cycles:u 526,337,243,809 instructions:u # 2.05 insn per cycle 113,447,583,099 branches:u 383,121,251 branch-misses:u # 0.34% of all branches diff --git a/gcc/tree-into-ssa.cc b/gcc/tree-into-ssa.cc index d12a4a97f6..621793f7f4 100644 --- a/gcc/tree-into-ssa.cc +++ b/gcc/tree-into-ssa.cc @@ -805,21 +805,22 @@ prune_unused_phi_nodes (bitmap phis, bitmap kills, bi= tmap uses) locate the nearest dominating def in logarithmic time by binary searc= h.*/ bitmap_ior (to_remove, kills, phis); n_defs =3D bitmap_count_bits (to_remove); + adef =3D 2 * n_defs + 1; defs =3D XNEWVEC (struct dom_dfsnum, 2 * n_defs + 1); defs[0].bb_index =3D 1; defs[0].dfs_num =3D 0; - adef =3D 1; + struct dom_dfsnum *head =3D defs + 1, *tail =3D defs + adef; EXECUTE_IF_SET_IN_BITMAP (to_remove, 0, i, bi) { def_bb =3D BASIC_BLOCK_FOR_FN (cfun, i); - defs[adef].bb_index =3D i; - defs[adef].dfs_num =3D bb_dom_dfs_in (CDI_DOMINATORS, def_bb); - defs[adef + 1].bb_index =3D i; - defs[adef + 1].dfs_num =3D bb_dom_dfs_out (CDI_DOMINATORS, def_bb); - adef +=3D 2; + head->bb_index =3D i; + head->dfs_num =3D bb_dom_dfs_in (CDI_DOMINATORS, def_bb); + head++, tail--; + tail->bb_index =3D i; + tail->dfs_num =3D bb_dom_dfs_out (CDI_DOMINATORS, def_bb); } + gcc_assert (head =3D=3D tail); BITMAP_FREE (to_remove); - gcc_assert (adef =3D=3D 2 * n_defs + 1); qsort (defs, adef, sizeof (struct dom_dfsnum), cmp_dfsnum); gcc_assert (defs[0].bb_index =3D=3D 1);=