From patchwork Wed Jan 16 16:13:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 212793 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 006902C00A6 for ; Thu, 17 Jan 2013 03:14:09 +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=1358957651; 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=4fRQX4ZnW6bwF8l4kb1VBMb2Hmo=; b=mjku0fbb58Vol/c mX/4m3rMbO3zlk1KLbnmtNnMkRoYvFm/gU0zdJ8ihKBG6o5I8osJHZPMaOhX3et/ OB4CP+LQc+FJNt1gqL5Raeh2KUFEedaGuUol2HBQAoHdgvk6S4nFuh66l0joPN7m u4XeABVpOdJjkmljs9byZUzPbSfM= 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=qCpZuoHEKowIa3Et4W+Jtrbu6gyUmMW056jZQn2X8bTaEPY9MhOhu2kO6eRnbm gRgi4DWSfETigwIv79exLKdUGsnWIdlGKDvws0CWtZ0hco40/ow6NVPKaH3FMSfs 0rGSNstK1ypC9N0vkrVmJvMLZjF6D3xLrThtrCCyyM7RU=; Received: (qmail 20020 invoked by alias); 16 Jan 2013 16:14:00 -0000 Received: (qmail 19982 invoked by uid 22791); 16 Jan 2013 16:13:55 -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, 16 Jan 2013 16:13:48 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 2A36A542B30; Wed, 16 Jan 2013 17:13:47 +0100 (CET) Date: Wed, 16 Jan 2013 17:13:47 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix loop-iv.c ICE Message-ID: <20130116161346.GB3955@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 ICE seen in PR51083 on PPC. Here the flags ^= 0x80000000 expression is translated as PLUS. This makes us to consider flags to be IV and work out that the loop do not really iterate. It is a missed optimization that we do not work out this on all targets and do not unloop the loop at tree level. I opened PR for this. This patch fixes the ICE that we get confused on concluding that max number of iterations is 0. Bootstrapped/regtested x86_64-linux (where the code path do not really trigger obviously) and tested that it is fixing the testcase on PPC. OK? Honza PR tree-optimizatoin/51083 * gcc.c-torture/compile/pr51083.c: New testcase. * loop-iv.c (iv_number_of_iterations): Consider zero iteration case. Index: testsuite/gcc.c-torture/compile/pr51083.c =================================================================== --- testsuite/gcc.c-torture/compile/pr51083.c (revision 0) +++ testsuite/gcc.c-torture/compile/pr51083.c (revision 0) @@ -0,0 +1,18 @@ +extern int debug_threads; +extern void sigsuspend (void); +void my_waitpid (int flags, int wnohang) +{ + while (1) + { + if (flags & 0x80000000) + { + if (wnohang) + break; + if (debug_threads) + __builtin_puts ("blocking\n"); + sigsuspend (); + } + flags ^= 0x80000000; + } +} + Index: loop-iv.c =================================================================== --- loop-iv.c (revision 195144) +++ loop-iv.c (working copy) @@ -2819,7 +2819,8 @@ iv_number_of_iterations (struct loop *lo else { max = determine_max_iter (loop, desc, old_niter); - gcc_assert (max); + if (!max) + goto zero_iter_simplify; if (!desc->infinite && !desc->assumptions) record_niter_bound (loop, double_int::from_uhwi (max),