From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24055 invoked by alias); 27 May 2013 07:55:18 -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 23818 invoked by uid 55); 27 May 2013 07:55:14 -0000 From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/57343] [4.8/4.9 Regression] wrong code on x86_64-linux at -Os and above Date: Mon, 27 May 2013 07:55: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-Version: 4.9.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.8.1 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-05/txt/msg01856.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57343 --- Comment #8 from rguenther at suse dot de --- On Fri, 24 May 2013, rakdver at gcc dot gnu.org wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57343 > > --- Comment #7 from Zdenek Dvorak --- > (In reply to Richard Biener from comment #4) > > We then fall to > > > > if (multiple_of_p (TREE_TYPE (c), c, s)) > > { > > /* If C is an exact multiple of S, then its value will be reached > > before > > the induction variable overflows (unless the loop is exited in some > > other way before). Note that the actual induction variable in the > > loop (which ranges from base to final instead of from 0 to C) may > > overflow, in which case BNDS.up will not be giving a correct upper > > bound on C; thus, BNDS_U_VALID had to be computed in advance. */ > > no_overflow = true; > > exit_must_be_taken = true; > > > > which ends up with no_overflow = true and things going downhill from here. > > This is the problem -- multiple_of_p claims that (var * 100) is a multiple of > 100, which is not the case if the multiplication overflows. I am not sure > whether this is an expected behavior of multiple_of_p, or whether this could > cause problems in its other uses. > > A conservative fix here would be to replace the multiple_of_p test here by some > safer tests -- important special cases are: > 1) both c and s are constants and c is a multiple of s > 2) s = 1 Thanks. I'll audit other uses of multiple_of_p to see whether the current behavior is desired or a bug.