From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15789 invoked by alias); 20 Aug 2013 00:59:42 -0000 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 Received: (qmail 15755 invoked by uid 48); 20 Aug 2013 00:59:41 -0000 From: "bernd.edlinger at hotmail dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/58143] wrong code at -O3 on x86_64-linux-gnu Date: Tue, 20 Aug 2013 00:59:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bernd.edlinger at hotmail dot de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned 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: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-08/txt/msg00992.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58143 --- Comment #5 from Bernd Edlinger --- Summary: tree-ssa-loop-im.c moves code, out of an if statement inside the loop it it can not cause side effects or faults, but it does not care of integer overflows. this seems to be an optimization! BUT tree-ssa-loop-niter.c (infer_loop_bounds_from_signedness) does assume that the code will never execute integer additions or subtractions with the intention to use the result as modulo 2^32, thus ignoring overflow. It seems that -O3 and -fno-strict-overflow will fix the code. however this comment in tree.h points to another problem: IMPORTANT NOTE: Any optimization based on TYPE_OVERFLOW_UNDEFINED must issue a warning based on warn_strict_overflow. In some cases it will be appropriate to issue the warning immediately, and in other cases it will be appropriate to simply set a flag and let the caller decide whether a warning is appropriate or not. this example does not generate any warnings, not with -Wall and not with -Wstrict-overflow...