From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CBBD0385DC02; Tue, 29 Mar 2022 07:31:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CBBD0385DC02 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/105086] [12 Regression] Dead Code Elimination Regression at -Os (trunk vs. 11.2.0) 25 Date: Tue, 29 Mar 2022 07:31:04 +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: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.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 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: Tue, 29 Mar 2022 07:31:04 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105086 --- Comment #3 from Richard Biener --- (In reply to Andrew Macleod from comment #2) > Ranger VRP doesn't simulate edges the same way VRP does. It looks like VRP > simulates the back edge twice and the second time notes that the MAX value > is greater than it was before and "projects" the max to +INF to avoid > further simulations and thus executing every instance of the loop.=20 VRP uses optimistic SSA propagation with iteration, to avoid compile-time explosion we do not simulate IV ranges growing [0,0] -> [0, 1] ->...-> [0, = n] but instead do the cited projection and rely on SCEV to improve the resulting range. > This allows it to refine the range in the loop better, which ranger VRP > isn't doing as it is still doing a DOM walk and doesn't revisit the node. > ANd I haven't added any sort of similar "projection" logic to the back ed= ge > processing. I think ranger simply doesn't simulate SCCs (but I think that's OK) > I have an alternate question. it looks like when we utilize scev to pick= up > ranges we just give up if scev_probably_wraps_p() is true. >=20 > Analyzing # of iterations of loop 1 > exit condition 1 < [4294967273, + , 1] > bounds on difference of bases: 4294967272 ... 4294967272 > result: > # of iterations 23, bounded by 23 >=20 > Statement (exit)if (a_1 > 1) > is executed at most 23 (bounded by 23) + 1 times in loop 1. >=20 > but we neglect to create range for the PHI. We should be able to properly > create a range for this from the SCEV info rather than giving up? It wo= uld > be [0,0][4294967273, 4294967295].=20 Well, we give up if the IV wraps because then the logic we have to compute the IV range doesn't work. I'm talking about bounds_of_var_in_loop which basically computes the range as [base, base + step * niter] with adjustments to create proper ranges for negative step. > And even with the old value_range we could use anti-range and produce > ~[1, 4294967272]? It should use the range as computed by the "iteration", just not use SCEV to refine it. > Is there a practical reason we don't look any closer at wrap cases to see= if > they are "simple wraps" or not? I think that would also solve this issue. The only reason is that nobody implemented it. The important thing is to compute that it will wrap exactly once of course.=