From patchwork Wed Jan 9 15:06:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 210719 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 52CD52C0176 for ; Thu, 10 Jan 2013 02:06:51 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1358348811; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=2i/0+S7WsAJ6QiWyI3IPi69V/6M=; b=a2P4y1qOUYhvKc3 eB0K3oTBkDWYc41dqhdSL3zbwDxbHeOpCyHFNLPQ0/bnqrLZEm5eHwMAfERTctKZ MIEOHCwUasKwhmrywC9S63Jz03YhGOPaA1jWaPI5gZX315SixWKu+bywoeJ/LJdl pYxs2et7ZttcGcQw9PX5qGrpIGsE= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Date:From:To:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Hp3f4R+r4cYkPDEaWHonQ0BKcNhZW8MdAUeaHG3M/xE/fOq2Y2Kbg9LbCFLXlM 8Ik/g6brutAAmM3cmmDdAgGk8NSVVXzGI3iBk694IXzG8L+3sf3fEOPlKjUdHeaX 3UM577gvg9NpsD57o5UZXGXrsBZ+P0BqHdvfoAn9IHrhY=; Received: (qmail 31772 invoked by alias); 9 Jan 2013 15:06:42 -0000 Received: (qmail 31756 invoked by uid 22791); 9 Jan 2013 15:06:41 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 09 Jan 2013 15:06:34 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 116D8542BCD; Wed, 9 Jan 2013 16:06:33 +0100 (CET) Date: Wed, 9 Jan 2013 16:06:32 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: PR tree-optimization/55569 (profile updating ICE) Message-ID: <20130109150632.GC17341@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 Hi, this patch fixes problem with negative probabilities that result in overflow on ITERATION_BOUND parameter that is taken from niter code returning wider values than int. I went for gcov_type instead of HOST_WIDE_INT because it makes sense to derive the bounds from profile, too. Will commit it as obvious once bootstrap/regtest on x86_64 complette. Honza PR tree-optimization/55569 * cfgloopmanip.c (scale_loop_profile): Make ITERATION_BOUND gcov_type. * cfgloop.h (scale_loop_profile): Likewise. * gcc.c-torture/compile/pr55569.c: New testcase. Index: cfgloopmanip.c =================================================================== --- cfgloopmanip.c (revision 195047) +++ cfgloopmanip.c (working copy) @@ -481,7 +481,7 @@ scale_loop_frequencies (struct loop *loo to iterate too many times. */ void -scale_loop_profile (struct loop *loop, int scale, int iteration_bound) +scale_loop_profile (struct loop *loop, int scale, gcov_type iteration_bound) { gcov_type iterations = expected_loop_iterations_unbounded (loop); edge e; Index: cfgloop.h =================================================================== --- cfgloop.h (revision 195047) +++ cfgloop.h (working copy) @@ -711,7 +711,7 @@ extern void unroll_and_peel_loops (int); extern void doloop_optimize_loops (void); extern void move_loop_invariants (void); extern bool finite_loop_p (struct loop *); -extern void scale_loop_profile (struct loop *loop, int scale, int iteration_bound); +extern void scale_loop_profile (struct loop *loop, int scale, gcov_type iteration_bound); extern vec get_loop_hot_path (const struct loop *loop); /* Returns the outermost loop of the loop nest that contains LOOP.*/ Index: testsuite/gcc.c-torture/compile/pr55569.c =================================================================== --- testsuite/gcc.c-torture/compile/pr55569.c (revision 0) +++ testsuite/gcc.c-torture/compile/pr55569.c (revision 0) @@ -0,0 +1,11 @@ +/* { dg-options "-O1 -ftree-vectorize" } */ +int *bar (void); + +void +foo (void) +{ + long x; + int *y = bar (); + for (x = -1 / sizeof (int); x; --x, ++y) + *y = 0; +}