{"id":816172,"url":"http://patchwork.ozlabs.org/api/1.2/patches/816172/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/alpine.LSU.2.20.1709201406000.26836@zhemvz.fhfr.qr/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.2/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<alpine.LSU.2.20.1709201406000.26836@zhemvz.fhfr.qr>","list_archive_url":null,"date":"2017-09-20T12:07:27","name":"[GRAPHITE] Fix PR80213","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"1b6673bd3dd7dd50391c710fb253b94f4c61d605","submitter":{"id":4338,"url":"http://patchwork.ozlabs.org/api/1.2/people/4338/?format=json","name":"Richard Biener","email":"rguenther@suse.de"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/alpine.LSU.2.20.1709201406000.26836@zhemvz.fhfr.qr/mbox/","series":[{"id":4094,"url":"http://patchwork.ozlabs.org/api/1.2/series/4094/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=4094","date":"2017-09-20T12:07:27","name":"[GRAPHITE] Fix PR80213","version":1,"mbox":"http://patchwork.ozlabs.org/series/4094/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/816172/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/816172/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-return-462576-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-462576-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"XxnTELdo\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xxz5V2Qlsz9t2Q\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 20 Sep 2017 22:07:42 +1000 (AEST)","(qmail 33812 invoked by alias); 20 Sep 2017 12:07:34 -0000","(qmail 33357 invoked by uid 89); 20 Sep 2017 12:07:33 -0000","from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by\n\tsourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tWed, 20 Sep 2017 12:07:30 +0000","from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254])\tby\n\tmx1.suse.de (Postfix) with ESMTP id D1D92AE83\tfor\n\t<gcc-patches@gcc.gnu.org>; Wed, 20 Sep 2017 12:07:27 +0000 (UTC)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:subject:message-id:mime-version:content-type; q=dns; s=\n\tdefault; b=fFVv2AHHeYJbIgNZXo1r3BSicWcFVCDrFoF324gtdeh+sSKeFF76x\n\t2fhHIjzRGooTGNjAvDmoYK++XWoWEjsENDiTOKNHp1hONauGZ4A+HS9AazI51qeG\n\tl5p+gcS5U6JMsX5sZhpGPCHyOusPVWGxLHrUxMkPT32v0oKZx/dKCU=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:subject:message-id:mime-version:content-type; s=\n\tdefault; bh=kwoj0Yd2qmnxTPAa+M3oybuUmJM=; b=XxnTELdoaafgImDEj5Wc\n\tLpDD/3F5E25qJWkwWMKoycJRveOY3lGEojQPEXaYg5uMDZ5WJ6kGKi0x9JroZq5i\n\tRB+9JHeHa5O980ZbkasbtLkw6eoPCI4IDq5v4gJYkOA/B8ewz3qyiowSbwqCOvo3\n\taulF1gZQZ1Cv5UThTwH78Kg=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2,\n\tGIT_PATCH_3, RP_MATCHES_RCVD,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=ses, closest, 3567","X-HELO":"mx1.suse.de","Date":"Wed, 20 Sep 2017 14:07:27 +0200 (CEST)","From":"Richard Biener <rguenther@suse.de>","To":"gcc-patches@gcc.gnu.org","Subject":"[PATCH][GRAPHITE] Fix PR80213","Message-ID":"<alpine.LSU.2.20.1709201406000.26836@zhemvz.fhfr.qr>","User-Agent":"Alpine 2.20 (LSU 67 2015-01-07)","MIME-Version":"1.0","Content-Type":"text/plain; charset=US-ASCII"},"content":"The following fixes more cases of \"lost\" PHIs which happen because\nthe block with the loop-closed PHI nodes only get into the SCOP\nvia merge_sese.  But if we don't include that we do not handle\nreductions properly.\n\nFixed by always including that block in SESE regions.\n\nBootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.\n\nRichard.\n\n2017-09-20  Richard Biener  <rguenther@suse.de>\n\n\tPR tree-optimization/80213\n\t* graphite-scop-detection.c (trivially_empty_bb_p): Labels\n\tare allowed in empty BBs as well.\n\t(canonicalize_loop_closed_ssa): Also look for other complex\n\tedges.\n\t(scop_detection::get_sese): Include the loop-closed PHI block\n\tin loop SESEs.\n\t(scop_detection::merge_sese): Remove code adding extra blocks.\n\t(scop_detection::region_has_one_loop): Adjust for get_sese changes.\n\t(build_scops): Assert the final returned scop is invalid.","diff":"Index: gcc/graphite-scop-detection.c\n===================================================================\n--- gcc/graphite-scop-detection.c\t(revision 253001)\n+++ gcc/graphite-scop-detection.c\t(working copy)\n@@ -261,7 +261,8 @@ trivially_empty_bb_p (basic_block bb)\n   gimple_stmt_iterator gsi;\n \n   for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))\n-    if (gimple_code (gsi_stmt (gsi)) != GIMPLE_DEBUG)\n+    if (gimple_code (gsi_stmt (gsi)) != GIMPLE_DEBUG\n+\t&& gimple_code (gsi_stmt (gsi)) != GIMPLE_LABEL)\n       return false;\n \n   return true;\n@@ -355,7 +356,7 @@ canonicalize_loop_closed_ssa (loop_p loo\n   edge e = single_exit (loop);\n   basic_block bb;\n \n-  if (!e || e->flags & EDGE_ABNORMAL)\n+  if (!e || (e->flags & EDGE_COMPLEX))\n     return;\n \n   bb = e->dest;\n@@ -674,14 +675,19 @@ scop_detection::get_sese (loop_p loop)\n   if (!loop)\n     return invalid_sese;\n \n-  if (!loops_state_satisfies_p (LOOPS_HAVE_PREHEADERS))\n-    return invalid_sese;\n+  edge scop_begin = loop_preheader_edge (loop);\n   edge scop_end = single_exit (loop);\n-  if (!scop_end)\n+  if (!scop_end || (scop_end->flags & EDGE_COMPLEX))\n     return invalid_sese;\n-  edge scop_begin = loop_preheader_edge (loop);\n-  sese_l s (scop_begin, scop_end);\n-  return s;\n+  /* Include the BB with the loop-closed SSA PHI nodes.\n+     canonicalize_loop_closed_ssa makes sure that is in proper shape.  */\n+  if (! single_pred_p (scop_end->dest)\n+      || ! single_succ_p (scop_end->dest)\n+      || ! trivially_empty_bb_p (scop_end->dest))\n+    gcc_unreachable ();\n+  scop_end = single_succ_edge (scop_end->dest);\n+\n+  return sese_l (scop_begin, scop_end);\n }\n \n /* Return the closest dominator with a single entry edge.  */\n@@ -848,26 +854,6 @@ scop_detection::merge_sese (sese_l first\n       return invalid_sese;\n     }\n \n-  /* FIXME: We should remove this piece of code once\n-     canonicalize_loop_closed_ssa has been removed, because that function\n-     adds a BB with single exit.  */\n-  if (!trivially_empty_bb_p (get_exit_bb (combined)))\n-    {\n-      /* Find the first empty succ (with single exit) of combined.exit.  */\n-      basic_block imm_succ = combined.exit->dest;\n-      if (single_succ_p (imm_succ)\n-\t  && single_pred_p (imm_succ)\n-\t  && trivially_empty_bb_p (imm_succ))\n-\tcombined.exit = single_succ_edge (imm_succ);\n-      else\n-\t{\n-\t  DEBUG_PRINT (dp << \"[scop-detection-fail] Discarding SCoP because \"\n-\t\t\t  << \"no single exit (empty succ) for sese exit\";\n-\t\t       print_sese (dump_file, combined));\n-\t  return invalid_sese;\n-\t}\n-    }\n-\n   /* Analyze all the BBs in new sese.  */\n   if (harmful_loop_in_region (combined))\n     return invalid_sese;\n@@ -1027,7 +1013,8 @@ scop_detection::region_has_one_loop (ses\n     return false;\n \n   /* Otherwise, check whether we have adjacent loops.  */\n-  return begin->dest->loop_father == end->src->loop_father;\n+  return (single_pred_p (end->src)\n+\t  && begin->dest->loop_father == single_pred (end->src)->loop_father);\n }\n \n /* Add to SCOPS a scop starting at SCOP_BEGIN and ending at SCOP_END.  */\n@@ -2053,8 +2040,12 @@ build_scops (vec<scop_p> *scops)\n \n   canonicalize_loop_closed_ssa_form ();\n \n+  /* ???  We walk the loop tree assuming loop->next is ordered.\n+     This is not so but we'd be free to order it here.  */\n   scop_detection sb;\n-  sb.build_scop_depth (scop_detection::invalid_sese, current_loops->tree_root);\n+  sese_l tem = sb.build_scop_depth (scop_detection::invalid_sese,\n+\t\t\t\t    current_loops->tree_root);\n+  gcc_assert (! tem);\n \n   /* Now create scops from the lightweight SESEs.  */\n   vec<sese_l> scops_l = sb.get_scops ();\n","prefixes":["GRAPHITE"]}