From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C97183857C4E; Wed, 10 Nov 2021 09:53:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C97183857C4E From: "aldyh at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102906] [12 regression] gcc.target/arm/ivopts-4.c fails since r12-4526 Date: Wed, 10 Nov 2021 09:53:39 +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: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: aldyh at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: aldyh at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: assigned_to 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: Wed, 10 Nov 2021 09:53:39 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102906 Aldy Hernandez changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |aldyh at gcc dot gn= u.org --- Comment #14 from Aldy Hernandez --- (In reply to rguenther@suse.de from comment #13) > On Wed, 10 Nov 2021, aldyh at gcc dot gnu.org wrote: > > So, we could fix this either by relaxing the restriction with your patc= h, or by > > teaching should_duplicate_loop_header_p that an incoming edge can resol= ve the > > conditional in the header? >=20 > Yes. I think the latter would be cleaner but the former has an (ugly) > patch already (see above). Not sure how difficult it is to do the latter, The idea is actually straightforward. Assuming I have the right edge, this would get us the result: @@ -60,6 +63,24 @@ should_duplicate_loop_header_p (basic_block header, class loop *loop, if (optimize_loop_for_size_p (loop) && !loop->force_vectorize) { + if (gcond *last =3D safe_dyn_cast (last_stmt (header))) + { + gimple_ranger ranger; + int_range<2> r; + path_range_query path (ranger, /*resolve=3D*/true); + auto_vec bbs (2); + edge e =3D loop_preheader_edge (loop); + + gcc_checking_assert (e->dest =3D=3D header); + bbs.quick_push (header); + bbs.quick_push (e->src); + bitmap imports =3D ranger.gori ().imports (header); + path.compute_ranges (bbs, imports); + path.range_of_stmt (r, last); + r.dump (); + fputc ('\n', stderr); + } + if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, $ ./cc1 a.c -quiet -I/tmp -Os _Bool [1, 1] which means the final conditional in the path evaluates to true. I'll come up with an actual patch. The gori imports stuff can be hidden aw= ay in the path solver and we should have a ranger available for the entire pas= s, not instantiate a new one every time. > you are likely 10x quicker than me to figure that out ;) Well, only because you did all the hard work here :).=