From patchwork Wed Oct 18 14:33:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 827635 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-464453-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="hII2Rvn1"; dkim-atps=neutral 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 3yHF1c5xf1z9t4P for ; Thu, 19 Oct 2017 01:34:11 +1100 (AEDT) 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:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=oBWyg03VbYLzFVAUyx2wi+IUrlvEmAr7E/1nHGMfC+otWneo6s i0vg9ftNc1GgkVktLGnCRixKcY5IOH7jYEAKGZVDk4Zz+17iMjNiOSfX1x2d+2hb k+v5Gtc858cfhr1iRTYpeapbm8PIV1CyGJNQdtkL3tv2tMb1KjXVEX9wQ= 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:cc:subject:message-id:mime-version:content-type; s= default; bh=QVmwtwy3secwEKEhNULdXNVvvzY=; b=hII2Rvn1aGhVBgYPU/mL pJ1/PcZs1o57RUI1+RRlN4n2qyUKsKuw9slOm3o6uLg2Q3fd8g1+u7irDIjNbhbZ wya2pYBmCI1MD8dtwPupktHbpG51TKCFvu7T+2xxhSyARtnmrEoZjbbFZ4bgiN// oJd8084jm0qDtEosjZkkXEI= Received: (qmail 55963 invoked by alias); 18 Oct 2017 14:34:03 -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 55950 invoked by uid 89); 18 Oct 2017 14:34:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Oct 2017 14:34:01 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CF07DAB22; Wed, 18 Oct 2017 14:33:56 +0000 (UTC) Date: Wed, 18 Oct 2017 16:33:56 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: sebpop@gmail.com Subject: [PATCH][GRAPHITE] Limit AST code generation, PR82591 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 The following limits ISL operations done during optimized AST generation as the PR shows it can take quite a bit of time. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2017-10-18 Richard Biener PR tree-optimization/82591 * graphite.c (graphite_transform_loops): Move code gen message printing ... * graphite-isl-ast-to-gimple.c (graphite_regenerate_ast_isl): Here. Handle scop_to_isl_ast failing. (scop_to_isl_ast): Limit the number of ISL operations. Index: gcc/graphite.c =================================================================== --- gcc/graphite.c (revision 253848) +++ gcc/graphite.c (working copy) @@ -378,16 +380,14 @@ graphite_transform_loops (void) if (!apply_poly_transforms (scop)) continue; - location_t loc = find_loop_location - (scops[i]->scop_info->region.entry->dest->loop_father); - changed = true; - if (!graphite_regenerate_ast_isl (scop)) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc, - "loop nest not optimized, code generation error\n"); - else - dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, - "loop nest optimized\n"); + if (graphite_regenerate_ast_isl (scop)) + { + location_t loc = find_loop_location + (scops[i]->scop_info->region.entry->dest->loop_father); + dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, + "loop nest optimized\n"); + } } if (changed) Index: gcc/graphite-isl-ast-to-gimple.c =================================================================== --- gcc/graphite-isl-ast-to-gimple.c (revision 253848) +++ gcc/graphite-isl-ast-to-gimple.c (working copy) @@ -56,6 +56,7 @@ along with GCC; see the file COPYING3. #include "cfganal.h" #include "value-prof.h" #include "tree-ssa.h" +#include "tree-vectorizer.h" #include "graphite.h" struct ast_build_info @@ -1378,6 +1341,13 @@ ast_build_before_for (__isl_keep isl_ast __isl_give isl_ast_node *translate_isl_ast_to_gimple:: scop_to_isl_ast (scop_p scop) { + int old_err = isl_options_get_on_error (scop->isl_context); + int old_max_operations = isl_ctx_get_max_operations (scop->isl_context); + int max_operations = PARAM_VALUE (PARAM_MAX_ISL_OPERATIONS); + if (max_operations) + isl_ctx_set_max_operations (scop->isl_context, max_operations); + isl_options_set_on_error (scop->isl_context, ISL_ON_ERROR_CONTINUE); + gcc_assert (scop->transformed_schedule); /* Set the separate option to reduce control flow overhead. */ @@ -1396,6 +1366,27 @@ scop_to_isl_ast (scop_p scop) isl_ast_node *ast_isl = isl_ast_build_node_from_schedule (context_isl, schedule); isl_ast_build_free (context_isl); + + isl_options_set_on_error (scop->isl_context, old_err); + isl_ctx_reset_operations (scop->isl_context); + isl_ctx_set_max_operations (scop->isl_context, old_max_operations); + if (isl_ctx_last_error (scop->isl_context) != isl_error_none) + { + location_t loc = find_loop_location + (scop->scop_info->region.entry->dest->loop_father); + if (isl_ctx_last_error (scop->isl_context) == isl_error_quota) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc, + "loop nest not optimized, AST generation timed out " + "after %d operations [--param max-isl-operations]\n", + max_operations); + else + dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc, + "loop nest not optimized, ISL AST generation " + "signalled an error\n"); + isl_ast_node_free (ast_isl); + return NULL; + } + return ast_isl; } @@ -1444,6 +1435,12 @@ graphite_regenerate_ast_isl (scop_p scop timevar_push (TV_GRAPHITE_CODE_GEN); t.add_parameters_to_ivs_params (scop, ip); root_node = t.scop_to_isl_ast (scop); + if (! root_node) + { + ivs_params_clear (ip); + timevar_pop (TV_GRAPHITE_CODE_GEN); + return false; + } if (dump_file && (dump_flags & TDF_DETAILS)) { @@ -1484,10 +1481,10 @@ graphite_regenerate_ast_isl (scop_p scop if (t.codegen_error_p ()) { - if (dump_file) - fprintf (dump_file, "codegen error: " - "reverting back to the original code.\n"); - set_ifsese_condition (if_region, integer_zero_node); + location_t loc = find_loop_location + (scop->scop_info->region.entry->dest->loop_father); + dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc, + "loop nest not optimized, code generation error\n"); /* Remove the unreachable region. */ remove_edge_and_dominated_blocks (if_region->true_region->region.entry);