From patchwork Mon Nov 29 17:19:05 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 73460 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id A9E421007D1 for ; Tue, 30 Nov 2010 04:19:23 +1100 (EST) Received: (qmail 24484 invoked by alias); 29 Nov 2010 17:19:16 -0000 Received: (qmail 24459 invoked by uid 22791); 29 Nov 2010 17:19:15 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, TW_ZJ, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-pv0-f175.google.com (HELO mail-pv0-f175.google.com) (74.125.83.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 29 Nov 2010 17:19:08 +0000 Received: by pvd12 with SMTP id 12so938546pvd.20 for ; Mon, 29 Nov 2010 09:19:07 -0800 (PST) MIME-Version: 1.0 Received: by 10.142.172.10 with SMTP id u10mr5749812wfe.232.1291051145456; Mon, 29 Nov 2010 09:19:05 -0800 (PST) Received: by 10.143.6.4 with HTTP; Mon, 29 Nov 2010 09:19:05 -0800 (PST) In-Reply-To: References: Date: Mon, 29 Nov 2010 18:19:05 +0100 Message-ID: Subject: Re: [PATCH, committed]: Fix PR 46675, Profiledbootstrap failed From: Uros Bizjak To: gcc-patches@gcc.gnu.org Cc: Zdenek Dvorak , Richard Guenther , "H.J. Lu" , Andrew Haley Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On Mon, Nov 29, 2010 at 6:17 PM, Uros Bizjak wrote: > Hello! > > The fix is by Zdenek: > > Fixes overflow in # of iterations analysis -- when splitting var - INT_MIN to a > sum of a variable part and a constant offset, we performed the negation of the > offset in the original type (which overflows for INT_MIN) instead of in full > precision. > > 2010-11-29  Zdenek Dvorak   > >        PR tree-optimization/46675 >        * tree-ssa-loop-niter.c (split_to_var_and_offset): Avoid overflow >        in offset calculation. > > testsuite/ChangeLog: > > 2010-11-29  Richard Guenther   >            Zdenek Dvorak   > >        PR tree-optimization/46675 >        * gcc.dg/pr46675.c: New test. > > Patch was tested on x86_64-pc-linux-gnu {,-m32} with a profiled > bootstrap of all default languages. > > The patch was approved by Richi in the PR as obvious and was committed > to SVN mainline. > > BTW: H.J. has set a profiledbootstrap tester on gnu-16.sc... host, see > current results at [1]. > > [1] http://gcc.gnu.org/ml/gcc-testresults/2010-11/msg02438.html Now with the patch attached. Uros. Index: tree-ssa-loop-niter.c =================================================================== --- tree-ssa-loop-niter.c (revision 167252) +++ tree-ssa-loop-niter.c (working copy) @@ -95,10 +95,10 @@ split_to_var_and_offset (tree expr, tree *var = op0; /* Always sign extend the offset. */ off = tree_to_double_int (op1); - if (negate) - off = double_int_neg (off); off = double_int_sext (off, TYPE_PRECISION (type)); mpz_set_double_int (offset, off, false); + if (negate) + mpz_neg (offset, offset); break; case INTEGER_CST: Index: testsuite/gcc.dg/pr46675.c =================================================================== --- testsuite/gcc.dg/pr46675.c (revision 0) +++ testsuite/gcc.dg/pr46675.c (revision 0) @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +int j; + +void +__attribute__((noinline)) +foo (int n) +{ + int npairs, i; + npairs = n - (-__INT_MAX__ - 1); + + if (npairs > 0) + for (i = 0; i < npairs; i++) + j++; +} + +int +main () +{ + foo (5 - __INT_MAX__ - 1); + + if (j != 5) + abort (); + + return 0; +}