From patchwork Thu Oct 12 14:08:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 824895 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-464033-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="j8Qsvl2c"; 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 3yCXkX1vhqz9t2c for ; Fri, 13 Oct 2017 01:08:19 +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=tIZdaN7uM32YV2I0yxoeDjpMOWwkVtF/NtdS+7hpr1W4ykYOff e8K5Nh1B8dsV9sMayv3CpIeC+WxgvXxkk9m31gwmTKL5WG3TX9e6rF5qX/E+HXhM IBRi5KlSjvNXEJIm0UCemn6QkbiH3Eeko0LMZiGE4rCEv8XLg8oph3l80= 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=aDM7O1rTWJ4BxZ6eCU5Zy34wlds=; b=j8Qsvl2c4p4uAV00kUaa 8CHR+a7sdjnjl5Uk1QsLXrN+jbffHE20J+gxbHv+PQaaKVjRNtEdjGALzNUqo72k KgQUfgZMyh2JFJUOBv5Bb8W1iC4ppOsqkwfZ9GpmM8breZNfTGditrCqJqBjyl/c ycQqzuSJLvytMLkRiVbK2wE= Received: (qmail 58996 invoked by alias); 12 Oct 2017 14:08:07 -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 58949 invoked by uid 89); 12 Oct 2017 14:08:07 -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=figures, forgot 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; Thu, 12 Oct 2017 14:08:06 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C6287AAF1; Thu, 12 Oct 2017 14:08:03 +0000 (UTC) Date: Thu, 12 Oct 2017 16:08:03 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: sebpop@gmail.com Subject: [PATCH][GRAPHITE] Fix PR69728 in "another" way Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 I made scheduling to fail when we end up with an empty domain but as I forgot to actually check the return value of build_original_schedule the fix was equivalent to just doing nothing to the schedule when it has an empty domain. I verified that for the testcase it DCEs the relevant stmt and that this is a valid transform. Bootstrapped and tested on x86_64-unknown-linux-gnu, SPEC 2k6 is also happy with this. Committed as obvious (since no functional change). Richard. 2017-10-12 Richard Biener PR tree-optimization/69728 Revert 2017-09-19 Richard Biener PR tree-optimization/69728 * graphite-sese-to-poly.c (schedule_error): New global. (add_loop_schedule): Handle empty domain by failing the schedule. (build_original_schedule): Handle schedule_error. * graphite-sese-to-poly.c (add_loop_schedule): Handle empty domain by returning an unchanged schedule. * gcc.dg/graphite/pr69728.c: Adjust to reflect we can handle the loop now. Remove unrelated undefined behavior. Index: gcc/graphite-sese-to-poly.c =================================================================== --- gcc/graphite-sese-to-poly.c (revision 253645) +++ gcc/graphite-sese-to-poly.c (working copy) @@ -1066,8 +1051,6 @@ outer_projection_mupa (__isl_take isl_un return isl_multi_union_pw_aff_from_union_pw_multi_aff (data.res); } -static bool schedule_error; - /* Embed SCHEDULE in the constraints of the LOOP domain. */ static isl_schedule * @@ -1082,11 +1065,9 @@ add_loop_schedule (__isl_take isl_schedu return empty < 0 ? isl_schedule_free (schedule) : schedule; isl_union_set *domain = isl_schedule_get_domain (schedule); - /* We cannot apply an empty domain to pbbs in this loop so fail. - ??? Somehow drop pbbs in the loop instead. */ + /* We cannot apply an empty domain to pbbs in this loop so return early. */ if (isl_union_set_is_empty (domain)) { - schedule_error = true; isl_union_set_free (domain); return schedule; } @@ -1216,8 +1197,6 @@ build_schedule_loop_nest (scop_p scop, i static bool build_original_schedule (scop_p scop) { - schedule_error = false; - int i = 0; int n = scop->pbbs.length (); while (i < n) @@ -1232,14 +1211,6 @@ build_original_schedule (scop_p scop) scop->original_schedule = add_in_sequence (scop->original_schedule, s); } - if (schedule_error) - { - if (dump_file) - fprintf (dump_file, "[sese-to-poly] failed to build " - "original schedule\n"); - return false; - } - if (dump_file) { fprintf (dump_file, "[sese-to-poly] original schedule:\n"); Index: gcc/testsuite/gcc.dg/graphite/pr69728.c =================================================================== --- gcc/testsuite/gcc.dg/graphite/pr69728.c (revision 253645) +++ gcc/testsuite/gcc.dg/graphite/pr69728.c (working copy) @@ -1,7 +1,7 @@ /* { dg-do compile } */ -/* { dg-options "-O3 -floop-nest-optimize" } */ +/* { dg-options "-O3 -floop-nest-optimize -fdump-tree-graphite-details" } */ -int a[1]; +int a[9]; int b, c, d, e; void fn1 () @@ -19,3 +19,9 @@ fn1 () } } } + +/* At the moment only ISL figures that if (d) is always true. We've + run into scheduling issues before here, not being able to handle + empty domains. */ + +/* { dg-final { scan-tree-dump "loop nest optimized" "graphite" } } */