From patchwork Wed May 18 16:17:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 623650 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 3r8zs51JZBz9t6M for ; Thu, 19 May 2016 02:18:32 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=qES0tIk2; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=cmikdNbJKqPVn+bRrgsvbC/1dTQKcV6xCX6RspwhQTJyizDm5Pa/t wW+OXO+rycjUcUNirNhUvCLN0/wcWmXACvGR22TCDdVAF48Ze+IY4I1BYeQVgmqs u20JMJFM2YdjO0T3nNo5JE16xlO7dD829e06Pk/5/JtsMQEe68d5wk= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=cMSr4VhNrcqFGB1/378k1n/n5QY=; b=qES0tIk2ELcFtfVeyLdF r8XmrF04uFx9bEWtf9Kz1vHDdbdXaqCw7zdMLGV8bimCyn8GDhJ9mK1UupwTkYhI Y1IPsRKApav4uMe17Cjok+SG18muM/kljC34aIa6eg3xlJOWQ3n3+Qpvj63U96CM 1e5vrHxp2PhPNn3jYt9c+mA= Received: (qmail 83641 invoked by alias); 18 May 2016 16:18:23 -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 83616 invoked by uid 89); 18 May 2016 16:18:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:!flag_r, sk:flag_r X-HELO: mail-wm0-f67.google.com Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 18 May 2016 16:18:07 +0000 Received: by mail-wm0-f67.google.com with SMTP id r12so14155414wme.0 for ; Wed, 18 May 2016 09:18:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=u6EMS5J9LJs4X+LuXQeyLz1eV9brBsQZIMphY0H5ldU=; b=j7tPmFapxv4g0fN9bdbdqgqb+czNLNxG40pVQ1ZraI01UFMcC1MBpN8jSB9VUOx4Iq 4/pH9afhxDTra27+UWEkUkpDkjuT7ez55Xk57X4bPx0M0ezHPjaifDkPZIiAZ4k5hwNy l/DfOdztuTAtYrrI+jncd64Hri8opzk1asV5f1eLchbugq1Y8dE7JlGrEDogFLwIiQoB px4UMjPGTZoKM5WNxWPAdViXfwU0Dw/E3jE9BMKpQ0uUBpEDVIgF2yRpZqyIQJUNd8vw 8fWivBB18z1BhkJw+QjZlGTmZavFd0qJqOfnHS8pgBw9PwYrCvFSJrGxj7tffcirtTxT OKyg== X-Gm-Message-State: AOPr4FWGjjPajdAgqU2gUUYkp8W/0fiFWs60ArEWzaxePybNcmuRaxWZcCTVUjufqOPDaA== X-Received: by 10.28.211.10 with SMTP id k10mr31157065wmg.82.1463588284936; Wed, 18 May 2016 09:18:04 -0700 (PDT) Received: from msticlxl57.ims.intel.com (irdmzpr01-ext.ir.intel.com. [192.198.151.36]) by smtp.gmail.com with ESMTPSA id jd4sm9446956wjb.43.2016.05.18.09.18.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 May 2016 09:18:04 -0700 (PDT) Date: Wed, 18 May 2016 19:17:03 +0300 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH, PR rtl-optimization/71148] Avoid cleanup_cfg called with invalidated dominance info Message-ID: <20160518161703.GA31178@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Hi, This patch resolves PR71148 by releasing dominance info before cleanup_cfg calls to avoid attempts to fixup invalid dominance info. Dominance info handling in cleanup_cfg looks weird though. It tries to fix it but can invalidate it at the same time (PR71084). We should probably do something with that. Tracker is P1 and this patch may be OK solution for now. Bootstrapped and regtested on x86_64-pc-linux-gnu. Ok for trunk? Thanks, Ilya --- gcc/ 2016-05-18 Ilya Enkovich PR rtl-optimization/71148 * cse.c (rest_of_handle_cse): Free dominance info before cleanup_cfg call if required. (rest_of_handle_cse2): Likewise. (rest_of_handle_cse_after_global_opts): Likewise. gcc/testsuite/ 2016-05-18 Ilya Enkovich PR rtl-optimization/71148 * gcc.dg/pr71148.c: New test. diff --git a/gcc/cse.c b/gcc/cse.c index 322e352..4aa4443 100644 --- a/gcc/cse.c +++ b/gcc/cse.c @@ -7558,6 +7558,12 @@ rest_of_handle_cse (void) expecting CSE to be run. But always rerun it in a cheap mode. */ cse_not_expected = !flag_rerun_cse_after_loop && !flag_gcse; + /* Check if we need to free dominance info before cleanup_cfg + because it may become really slow in case of invalid + dominance info. */ + if (cse_cfg_altered && dom_info_available_p (CDI_DOMINATORS)) + free_dominance_info (CDI_DOMINATORS); + if (tem == 2) { timevar_push (TV_JUMP); @@ -7630,6 +7636,12 @@ rest_of_handle_cse2 (void) delete_trivially_dead_insns (get_insns (), max_reg_num ()); + /* Check if we need to free dominance info before cleanup_cfg + because it may become really slow in case of invalid + dominance info. */ + if (cse_cfg_altered && dom_info_available_p (CDI_DOMINATORS)) + free_dominance_info (CDI_DOMINATORS); + if (tem == 2) { timevar_push (TV_JUMP); @@ -7706,6 +7718,12 @@ rest_of_handle_cse_after_global_opts (void) cse_not_expected = !flag_rerun_cse_after_loop; + /* Check if we need to free dominance info before cleanup_cfg + because it may become really slow in case of invalid + dominance info. */ + if (cse_cfg_altered && dom_info_available_p (CDI_DOMINATORS)) + free_dominance_info (CDI_DOMINATORS); + /* If cse altered any jumps, rerun jump opts to clean things up. */ if (tem == 2) { diff --git a/gcc/testsuite/gcc.dg/pr71148.c b/gcc/testsuite/gcc.dg/pr71148.c new file mode 100644 index 0000000..6aa4920 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr71148.c @@ -0,0 +1,46 @@ +/* PR rtl-optimization/71148 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -funroll-loops" } */ + +int rh, ok, kq, fu; + +void +js (int cs) +{ + rh = fu; + if (fu != 0) + { + cs /= 3; + if (cs <= 0) + { + int z9; + for (z9 = 0; z9 < 2; ++z9) + { + z9 += cs; + ok += z9; + fu += ok; + } + } + } +} + +void +vy (int s3) +{ + int yo, g2 = 0; + sd: + js (g2); + for (yo = 0; yo < 2; ++yo) + { + if (fu != 0) + goto sd; + kq += (s3 != (g2 ? s3 : 0)); + for (s3 = 0; s3 < 72; ++s3) + g2 *= (~0 - 1); + g2 -= yo; + } + for (fu = 0; fu < 18; ++fu) + for (yo = 0; yo < 17; ++yo) + if (g2 < 0) + goto sd; +}