From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17794 invoked by alias); 11 Mar 2013 15:59:20 -0000 Received: (qmail 17640 invoked by uid 48); 11 Mar 2013 15:58:42 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/53265] Warn when undefined behavior implies smaller iteration count Date: Mon, 11 Mar 2013 15:59:00 -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-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-03/txt/msg00866.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53265 --- Comment #9 from Richard Biener 2013-03-11 15:58:41 UTC --- (In reply to comment #8) > Created attachment 29637 [details] > gcc48-pr53265.patch > > Untested patch. Not sure about the warning wording, plus no idea how to call > the warning option (-Wnum-loop-iterations, -Wundefined-behavior-in-loop, > something else?), whether to enable it by default, or just for -Wall. > A bigger issue is that I see multiple warnings for the same stmts, despite the > guard in loop structure, because apparently the same loop is represented by > different loop structures during the optimizations. Yeah, before the tree loop optimization pipeline loops are not preserved ... (easy to change, apart from code missing to inline a loop tree). Eventually use gimple_no_warning on the stmt? Supposedly not very reliable either. I think with your patch you also fail to warn for bounds discovered by discover_iteration_bound_by_body_walk or maybe_lower_iteration_bound. That said, I'd expected you warn from within record_niter_bound. Btw, after number_of_latch_executions () its return value is cached in loop->nb_iterations, no need to pass around another value.