{"id":814795,"url":"http://patchwork.ozlabs.org/api/1.2/patches/814795/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/alpine.LSU.2.20.1709180928410.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.1709180928410.26836@zhemvz.fhfr.qr>","list_archive_url":null,"date":"2017-09-18T07:31:00","name":"Fix PR79622","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"93c89e99d637c749c11ea14a65ce6600f6f99039","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.1709180928410.26836@zhemvz.fhfr.qr/mbox/","series":[{"id":3570,"url":"http://patchwork.ozlabs.org/api/1.2/series/3570/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=3570","date":"2017-09-18T07:31:00","name":"Fix PR79622","version":1,"mbox":"http://patchwork.ozlabs.org/series/3570/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/814795/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/814795/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-return-462351-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-462351-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=\"e81Z/X9N\"; 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 3xwd3X1gnhz9ryQ\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 18 Sep 2017 17:31:17 +1000 (AEST)","(qmail 87682 invoked by alias); 18 Sep 2017 07:31:10 -0000","(qmail 85364 invoked by uid 89); 18 Sep 2017 07:31:05 -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\tMon, 18 Sep 2017 07:31:04 +0000","from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254])\tby\n\tmx1.suse.de (Postfix) with ESMTP id 242B6AAC5\tfor\n\t<gcc-patches@gcc.gnu.org>; Mon, 18 Sep 2017 07:31:01 +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=JWmd0E+ePf03R19130hnpJrt/I2+xfkHG1vW+sKHL/jX6CQVUarNq\n\thzoZS1ieoUPe5sIsbHgFufCMHWxVImk/DmEA2Cr8g/W0wT/cehsq6Smv9iYc39rf\n\twwvwO9JXL33TqB6MgnKxrDN7poYDXrapzwx+8dNQqfrFCHEUYQ0T+E=","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=FFFABqLzqpNeOX86pFyQL9nV9UU=; b=e81Z/X9NnGu8UGeGWKRL\n\th6Y5JVDVIYbeOouwHAAzuqWsDcAbl0IRYlTf3oTfg55Say90k2T8MXQ53934fQ4h\n\t20hgQoszbzO+jIlqCKmn8xW9bVQhNCBL4//9vl69jz0xDg45m0RA/dDAgweJwSLN\n\ttB/HsS2lkgcFu3hML5hXDwk=","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.1 required=5.0 tests=BAYES_00, GIT_PATCH_2,\n\tGIT_PATCH_3, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=mishandling","X-HELO":"mx1.suse.de","Date":"Mon, 18 Sep 2017 09:31:00 +0200 (CEST)","From":"Richard Biener <rguenther@suse.de>","To":"gcc-patches@gcc.gnu.org","Subject":"[PATCH] Fix PR79622","Message-ID":"<alpine.LSU.2.20.1709180928410.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 patch fixes the other known wrong-code bug in GRAPHITE\nwhich shows we're mishandling PHIs in not properly considering the\nedge copies they represent as living outside of the black-box we're\nanalyzing.\n\nBootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.\n\nNote the testcase still fails with ISL 0.16.1 but passes with 0.18\nfor me.  I'll update the version in download_prerequesites to 0.18.\n\nRichard.\n\n2017-09-18  Richard Biener  <rguenther@suse.de>\n\n\tPR tree-optimization/79622\n\t* graphite-scop-detection.c (build_cross_bb_scalars_def): Properly\n\thandle PHIs.\n\t(build_cross_bb_scalars_use): Likewise.\n\n\t* gcc.dg/graphite/pr79622.c: New testcase.","diff":"Index: gcc/graphite-scop-detection.c\n===================================================================\n--- gcc/graphite-scop-detection.c\t(revision 252806)\n+++ gcc/graphite-scop-detection.c\t(working copy)\n@@ -1744,7 +1744,9 @@ build_cross_bb_scalars_def (scop_p scop,\n   gimple *use_stmt;\n   imm_use_iterator imm_iter;\n   FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, def)\n-    if (def_bb != gimple_bb (use_stmt) && !is_gimple_debug (use_stmt))\n+    if ((def_bb != gimple_bb (use_stmt) && !is_gimple_debug (use_stmt))\n+\t/* PHIs have their effect at \"BBs\" on the edges.  See PR79622.  */\n+\t|| gimple_code (SSA_NAME_DEF_STMT (def)) == GIMPLE_PHI)\n       {\n \twrites->safe_push (def);\n \tDEBUG_PRINT (dp << \"Adding scalar write: \";\n@@ -1758,7 +1760,8 @@ build_cross_bb_scalars_def (scop_p scop,\n       }\n }\n \n-/* Record DEF if it is used in other bbs different than DEF_BB in the SCOP.  */\n+/* Record USE if it is defined in other bbs different than USE_STMT\n+   in the SCOP.  */\n \n static void\n build_cross_bb_scalars_use (scop_p scop, tree use, gimple *use_stmt,\n@@ -1774,7 +1777,9 @@ build_cross_bb_scalars_use (scop_p scop,\n     return;\n \n   gimple *def_stmt = SSA_NAME_DEF_STMT (use);\n-  if (gimple_bb (def_stmt) != gimple_bb (use_stmt))\n+  if (gimple_bb (def_stmt) != gimple_bb (use_stmt)\n+      /* PHIs have their effect at \"BBs\" on the edges.  See PR79622.  */\n+      || gimple_code (def_stmt) == GIMPLE_PHI)\n     {\n       DEBUG_PRINT (dp << \"Adding scalar read: \";\n \t\t   print_generic_expr (dump_file, use);\nIndex: gcc/testsuite/gcc.dg/graphite/pr79622.c\n===================================================================\n--- gcc/testsuite/gcc.dg/graphite/pr79622.c\t(nonexistent)\n+++ gcc/testsuite/gcc.dg/graphite/pr79622.c\t(working copy)\n@@ -0,0 +1,26 @@\n+/* { dg-do run } */\n+/* { dg-options \"-O2 -floop-nest-optimize\" } */\n+\n+int bf;\n+\n+int\n+main (void)\n+{\n+  int dc[5];\n+\n+  for (bf = 0; bf < 2; ++bf)\n+    {\n+      int l9, g5 = -1;\n+\n+      for (l9 = 0; l9 < 5; ++l9)\n+\t{\n+\t  dc[l9] = g5;\n+\t  g5 = (dc[l9] > 0);\n+\t}\n+    }\n+\n+  if (dc[0] != -1)\n+    __builtin_abort ();\n+\n+  return 0;\n+}\n","prefixes":[]}