From patchwork Sun Nov 24 07:30:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Mi X-Patchwork-Id: 293734 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D6D4D2C00B7 for ; Sun, 24 Nov 2013 18:30:46 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; q=dns; s=default; b=WHZm7KXaVZ9DTgp4ra SvBYLclk5HfYBrsoNeuBqbmwaJCrfsuiAI87DNh2ZQM0fQHxNXz5l0VCvB/XGz3O nFfxRekrvm1hHTMq7Ckw3im4qnK9xbliTTywcMd4wSz0wTAIy99oKWor7XKCRT8Z X12R01cPP/vQ2tdxgD04bBMHs= 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 :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; s=default; bh=bmVgduDAvOfqW+S2sEOsA0X9 a3A=; b=ov5BNbHjZoxRNGXiNPrFFLeepvvhql2As6IRULV7/JmasQkQjjOMZ7jL I+13gYv5oyXWsi6F2WrVpXT3R4tzNiZIdHKTDAGMAbVYLWom3uNM4wbAvn18R1He gDcAgUr4BBcBOs++NwIvipS+YhukexaAi4aufg+lemq5wy7hEyE= Received: (qmail 26369 invoked by alias); 24 Nov 2013 07:30:36 -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 26360 invoked by uid 89); 24 Nov 2013 07:30:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, SPF_PASS, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mail-oa0-f50.google.com Received: from Unknown (HELO mail-oa0-f50.google.com) (209.85.219.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sun, 24 Nov 2013 07:30:34 +0000 Received: by mail-oa0-f50.google.com with SMTP id n16so3158524oag.9 for ; Sat, 23 Nov 2013 23:30:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=zjODB4l3dBqhpkqUqHZuebhLaw+ESKJYEHk1wWQ81Dw=; b=Yxfv2O5C7WW1xRz32RtYQRklebFdJFhOMYNVerJUEGTZ/KutVYfCPFA99PWbqcfB1y Lb9JWuDiCk8HGi5Zn7o+YQRVw1mc7hVXBkOXxmBoe5OTY7Mjw4Km+Ia03+oc8zicFSAE UUXAex8Rr1i7m7jfMFv6QQmFX3KWeYD/chKDFKCS7Wv56si0eFin0d2RltHIhinir4pq GxhHFy/9laKfTB4+kFz5+nXmGlzRXmItdKfc+6y0IqN4IfMmME6LMJbKQBxLW+yv7CZp WS2ZzEwI/muoRaiwjIDUoc8JxUlGrgrehd2yUWmcZp/hZE7ghJGmm5Kvyx8OFs70bbG/ +IHg== X-Gm-Message-State: ALoCoQkXIMIBDRLJ/AmHf92jaG1OVaMc4w8YQuYZvmMnEhy2kS7I06CPoRW0R16yjORlPB7yU9Z5oFI0VkuMm8t3DssRx2RhbVzhWrFLuDfACjck+zvBErnkNBYDMkxDaeHdkOJiQP6qxEJzFIUJWUcKZFl5577EoGijnxcezUobkCCfSIifPRKxXZQPmJrsU/8kHh93pbq3VFn8cuvHONUbxBIW1DOlTQ== MIME-Version: 1.0 X-Received: by 10.60.63.141 with SMTP id g13mr332005oes.60.1385278225982; Sat, 23 Nov 2013 23:30:25 -0800 (PST) Received: by 10.76.75.3 with HTTP; Sat, 23 Nov 2013 23:30:25 -0800 (PST) In-Reply-To: References: <20130924212516.GA11364@kam.mff.cuni.cz> <525DA6FF.5010901@redhat.com> <525EF180.4020708@redhat.com> <20131104011801.GB32134@atrey.karlin.mff.cuni.cz> Date: Sat, 23 Nov 2013 23:30:25 -0800 Message-ID: Subject: Re: Fwd: [PATCH] Scheduling result adjustment to enable macro-fusion From: Wei Mi To: "H.J. Lu" Cc: Jan Hubicka , Jeff Law , Alexander Monakov , Steven Bosscher , GCC Patches , David Li , Kirill Yukhin , Vladimir Makarov Sorry about the problem. For the failed testcase, it was compiled using -fmodulo-sched. modulo-sched phase set SCHED_GROUP_P of a jump insn to be true, which means the jump insn should be scheduled with prev insn as a group. When modulo scheduling is finished, the flag of SCHED_GROUP_P is not cleaned up. After that, pass_jump2 phase split the bb and move the prev insn to another bb. Then pass_sched2 see the flag and mistakenly try to bind the jump insn with a code label. I am thinking other cases setting SCHED_GROUP_P should have the same problem because SCHED_GROUP_P is not cleaned up after scheduling is done. The flag may become inconsistent after some optimizations and may cause problem if it is used by later scheduling passes. I don't know why similar problem was never exposed before. The fix is to simply cleanup SCHED_GROUP_P flag in sched_finish. bootstrap is ok. regression test is going on. Is it ok if regression passes? Thanks, Wei. 2013-11-23 Wei Mi PR rtl-optimization/59020 * haifa-sched.c (cleanup_sched_group): New function. (sched_finish): Call cleanup_sched_group to cleanup SCHED_GROUP_P. 2013-11-23 Wei Mi PR rtl-optimization/59020 * testsuite/gcc.dg/pr59020.c (void f): On Sat, Nov 23, 2013 at 4:34 PM, H.J. Lu wrote: > On Mon, Nov 4, 2013 at 1:51 PM, Wei Mi wrote: >> Thanks! The three patches are commited as r204367, r204369 and r204371. >> > > r204369 caused: > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59020 > > -- > H.J. Index: haifa-sched.c =================================================================== --- haifa-sched.c (revision 204923) +++ haifa-sched.c (working copy) @@ -6598,6 +6598,23 @@ group_insns_for_macro_fusion () try_group_insn (BB_END (bb)); } +/* Cleanup SCHED_GROUP_P after scheduling is done. This is necessary because + bb may be changed by other optimizations and the flag from last scheduling + may become invalid. If later scheduler see the flag generated from last + scheduling, it may produces incorrect result. */ + +static void +cleanup_sched_group () +{ + basic_block bb; + rtx insn; + + FOR_EACH_BB (bb) + FOR_BB_INSNS(bb, insn) + if (INSN_P (insn) && SCHED_GROUP_P (insn)) + SCHED_GROUP_P (insn) = 0; +} + /* Initialize some global state for the scheduler. This function works with the common data shared between all the schedulers. It is called from the scheduler specific initialization routine. */ @@ -6841,6 +6858,8 @@ sched_finish (void) } free (curr_state); + cleanup_sched_group (); + if (targetm.sched.finish_global) targetm.sched.finish_global (sched_dump, sched_verbose); Index: testsuite/gcc.dg/pr59020.c =================================================================== --- testsuite/gcc.dg/pr59020.c (revision 0) +++ testsuite/gcc.dg/pr59020.c (revision 0) @@ -0,0 +1,15 @@ +/* PR rtl-optimization/59020 */ + +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fmodulo-sched -fno-inline -march=corei7" } */ + +int a, b, d; +unsigned c; + +void f() +{ + unsigned q; + for(; a; a++) + if(((c %= d && 1) ? : 1) & 1) + for(; b; q++); +}