From patchwork Wed May 14 08:57:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Belevantsev X-Patchwork-Id: 348660 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 122401400A8 for ; Wed, 14 May 2014 18:57:13 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=LOh/aCLRFFZi6AGtOSBJwgW94+yHBWG+ufk8z26GMXv DVZAZBKny65o7P+LrmU/64JwX1kyIRUnUI7ncta/lKBkfPj5ynwRIy2nC15SDvfF sjit5W/eaNVmX4B3ZSKWa9PmH6/+Q5lbs9l2lHjBg+apvKTKTeLMKWStg+2NetyE = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=HJcyTiYpaQiKpdCh3S+pemUoqSs=; b=lPZAx7xBe2f7154ET KqciEc5gm1QLOw3JgNlea2xmPZTU4j+Ep80t+l00Ouvhrgf54hy/j9oS3D9zeIEK co3HJdJpPEbJ790JGHWdgEFaabDPMEgJ2k9qaLQe5FRfdmAV+/9G20nl//VwZ50h PZM30jG/HizGNan/oE2zMjh6qM= Received: (qmail 23676 invoked by alias); 14 May 2014 08:57:06 -0000 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 Received: (qmail 23666 invoked by uid 89); 14 May 2014 08:57:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail.ispras.ru Received: from mail.ispras.ru (HELO mail.ispras.ru) (83.149.199.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 May 2014 08:57:03 +0000 Received: from [10.10.3.52] (pluton2.ispras.ru [83.149.199.44]) by mail.ispras.ru (Postfix) with ESMTPSA id ECB2854015F; Wed, 14 May 2014 12:57:00 +0400 (MSK) Message-ID: <53732FE2.9010305@ispras.ru> Date: Wed, 14 May 2014 12:57:06 +0400 From: Andrey Belevantsev User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: GCC Patches CC: Uros Bizjak Subject: [PATCH] Fix PR 60901 X-IsSubscribed: yes Hello, This ICE comes from the ix86_dependencies_evaluation_hook code assumption that any scheduling region will be connected. This assumption is not correct in case of the outer loops pipelining of the selective scheduler as explained in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60901#c3. Trying to add dependencies between insns from the different scheduling regions results in a segfault within the dependency analyzer code. The fix is to adjust the code to account for the situation when basic block's predecessors do not belong to the same scheduling region. Bootstrapped and tested on x86-64, OK for trunk? Branches? The fix is low risk as the additional test should always be true for the regular scheduler. Yours, Andrey gcc/ 2014-05-14 Andrey Belevantsev PR rtl-optimization/60901 * config/i386/i386.c (ix86_dependencies_evaluation_hook): Check that bb predecessor belongs to the same scheduling region. Adjust comment. testsuite/ 2014-05-14 Andrey Belevantsev PR rtl-optimization/60901 * gcc.dg/pr60901.c: New test. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 99f0657..0274288 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -26254,13 +26254,17 @@ ix86_dependencies_evaluation_hook (rtx head, rtx tail) { edge e; edge_iterator ei; - /* Assume that region is SCC, i.e. all immediate predecessors - of non-head block are in the same region. */ + + /* Regions are SCCs with the exception of selective + scheduling with pipelining of outer blocks enabled. + So also check that immediate predecessors of a non-head + block are in the same region. */ FOR_EACH_EDGE (e, ei, bb->preds) { /* Avoid creating of loop-carried dependencies through - using topological odering in region. */ - if (BLOCK_TO_BB (bb->index) > BLOCK_TO_BB (e->src->index)) + using topological ordering in the region. */ + if (rgn == CONTAINING_RGN (e->src->index) + && BLOCK_TO_BB (bb->index) > BLOCK_TO_BB (e->src->index)) add_dependee_for_func_arg (first_arg, e->src); } } diff --git a/gcc/testsuite/gcc.dg/pr60901.c b/gcc/testsuite/gcc.dg/pr60901.c new file mode 100644 index 0000000..1350f16 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr60901.c @@ -0,0 +1,18 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* x86_64-*-* } } */ +/* { dg-options "-O -fselective-scheduling -fschedule-insns -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops -fno-tree-dominator-opts" } */ + +extern int n; +extern void bar (void); +extern int baz (int); + +void +foo (void) +{ + int i, j; + for (j = 0; j < n; j++) + { + for (i = 1; i < j; i++) + bar (); + baz (0); + } +}