[{"id":1760427,"web_url":"http://patchwork.ozlabs.org/comment/1760427/","msgid":"<3C61E728-0B35-4F69-82B7-97C73B0BFBA8@gmail.com>","list_archive_url":null,"date":"2017-08-30T19:31:14","subject":"Re: [PATCH] Fix PR81987 (SLSR dominance issue)","submitter":{"id":1765,"url":"http://patchwork.ozlabs.org/api/people/1765/","name":"Richard Biener","email":"richard.guenther@gmail.com"},"content":"On August 30, 2017 7:22:45 PM GMT+02:00, Bill Schmidt <wschmidt@linux.vnet.ibm.com> wrote:\n>Hi,\n>\n>https://gcc.gnu.org/PR81987 identifies an SSA verification error\n>following\n>SLSR.  The problem arises when SLSR places an initialization expression\n>at\n>a point not dominated by the definition of an SSA name it uses.  When\n>there\n>are multiple conditional candidates for replacement, the initialization\n>expression must dominate all of these candidates and their phi\n>dependencies,\n>but the nearest common dominator for these may actually be above the\n>stride\n>definition in some cases.\n>\n>In such cases a single initialization point is not possible.  With\n>sufficient\n>analysis, it would be possible to find multiple initialization points\n>that\n>would satisfy availability of the stride at the cost of larger code. \n>This\n>is too complex for a bug fix, though.  This patch instead refuses to\n>replace\n>candidates where a single legal initialization point isn't possible. \n>We\n>ensure this by setting the cost for the increment associated with this\n>initialization to effectively infinite.\n>\n>Bootstrapped and tested on powerpc64le-linux-gnu with no regressions. \n>Is\n>this okay for trunk, and backport to all supported releases after a\n>period\n>of burn-in?\n\nYes. \n\nThanks, \nRichard. \n\n>Thanks,\n>Bill\n>\n>\n>[gcc]\n>\n>2017-08-30  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>\n>\n>\tPR tree-optimization/81987\n>\t* gimple-ssa-strength-reduction.c (insert_initializers): Don't\n>\tinsert an initializer in a location not dominated by the stride\n>\tdefinition.\n>\n>[gcc/testsuite]\n>\n>2017-08-30  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>\n>\n>\tPR tree-optimization/81987\n>\t* g++.dg/torture/pr81987.C: New file.\n>\n>\n>Index: gcc/gimple-ssa-strength-reduction.c\n>===================================================================\n>--- gcc/gimple-ssa-strength-reduction.c\t(revision 251369)\n>+++ gcc/gimple-ssa-strength-reduction.c\t(working copy)\n>@@ -3340,6 +3340,23 @@ insert_initializers (slsr_cand_t c)\n> \t that block, the earliest one will be returned in WHERE.  */\n>       bb = nearest_common_dominator_for_cands (c, incr, &where);\n> \n>+      /* If the NCD is not dominated by the block containing the\n>+\t definition of the stride, we can't legally insert a\n>+\t single initializer.  Mark the increment as unprofitable\n>+\t so we don't make any replacements.  FIXME: Multiple\n>+\t initializers could be placed with more analysis.  */\n>+      gimple *stride_def = SSA_NAME_DEF_STMT (c->stride);\n>+      basic_block stride_bb = gimple_bb (stride_def);\n>+\n>+      if (stride_bb && !dominated_by_p (CDI_DOMINATORS, bb,\n>stride_bb))\n>+\t{\n>+\t  if (dump_file && (dump_flags & TDF_DETAILS))\n>+\t    fprintf (dump_file,\n>+\t\t     \"Initializer #%d cannot be legally placed\\n\", i);\n>+\t  incr_vec[i].cost = COST_INFINITE;\n>+\t  continue;\n>+\t}\n>+\n>       /* If the nominal stride has a different type than the recorded\n> \t stride type, build a cast from the nominal stride to that type.  */\n>       if (!types_compatible_p (TREE_TYPE (c->stride), c->stride_type))\n>Index: gcc/testsuite/g++.dg/torture/pr81987.C\n>===================================================================\n>--- gcc/testsuite/g++.dg/torture/pr81987.C\t(nonexistent)\n>+++ gcc/testsuite/g++.dg/torture/pr81987.C\t(working copy)\n>@@ -0,0 +1,61 @@\n>+extern short var_1;\n>+extern const short var_3;\n>+extern unsigned long int var_9;\n>+extern short var_13;\n>+extern const unsigned long int var_15;\n>+extern const unsigned long int var_37;\n>+extern unsigned long int var_40;\n>+extern long long int var_47;\n>+extern short var_48;\n>+extern const short var_54;\n>+extern long long int var_79;\n>+extern long long int var_81;\n>+extern long long int var_94;\n>+extern long long int var_95;\n>+extern long long int var_701;\n>+extern unsigned long int var_786;\n>+extern short var_788;\n>+extern long long int var_844;\n>+\n>+struct struct_1 {\n>+  short member_1_2 : 15;\n>+  static long long int member_1_3;\n>+};\n>+\n>+extern struct_1 struct_obj_6;\n>+extern struct_1 struct_obj_8;\n>+\n>+void foo() {\n>+  int a = var_3 <= 602154393864UL;\n>+  if (var_81 ? 0 : var_3 && var_9)\n>+    ;\n>+  else {\n>+    var_94 = 0;\n>+    if (var_3 && var_48 || var_13) {\n>+      if (var_48)\n>+\tvar_95 = 0;\n>+      short b((2364461588881776511UL + var_3) * (2 ? var_13 : 0) ||\n>var_1);\n>+      struct_obj_8.member_1_2 = b;\n>+      if (var_15) {\n>+\tif (var_81)\n>+\t  if (var_47)\n>+\t    ;\n>+\t  else if (var_40)\n>+\t    var_701 = 0;\n>+      } else {\n>+\tif (var_40)\n>+\t  var_79 = 0;\n>+\tif (var_54) {\n>+\t  if (var_37)\n>+\t    var_786 = 0;\n>+\t  else\n>+\t    var_788 = 0;\n>+\t            struct_obj_6.member_1_3 =\n>+\t\t      (2364461588881776511UL + var_3) * (2 ? var_13 : 0);\n>+\t}\n>+      }\n>+      if ((2364461588881776511UL + var_3) * (2 ? var_13 : 0))\n>+\tvar_844 = 0;\n>+    }\n>+  }\n>+}","headers":{"Return-Path":"<gcc-patches-return-461192-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-461192-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=\"FAlZmZP0\"; 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 3xjFxT3Fljz9sP5\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 05:31:41 +1000 (AEST)","(qmail 32460 invoked by alias); 30 Aug 2017 19:31:31 -0000","(qmail 32444 invoked by uid 89); 30 Aug 2017 19:31:31 -0000","from mail-wr0-f193.google.com (HELO mail-wr0-f193.google.com)\n\t(209.85.128.193) by sourceware.org\n\t(qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tWed, 30 Aug 2017 19:31:21 +0000","by mail-wr0-f193.google.com with SMTP id 40so4503344wrv.3 for\n\t<gcc-patches@gcc.gnu.org>; Wed, 30 Aug 2017 12:31:20 -0700 (PDT)","from android-f83b394395796e13.fritz.box\n\t(p5494E583.dip0.t-ipconnect.de. [84.148.229.131]) by\n\tsmtp.gmail.com with ESMTPSA id\n\ti24sm7435468wrc.95.2017.08.30.12.31.17 (version=TLS1_2\n\tcipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tWed, 30 Aug 2017 12:31:17 -0700 (PDT)"],"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:in-reply-to:references:mime-version:content-type\n\t:content-transfer-encoding:subject:to:from:message-id; q=dns; s=\n\tdefault; b=Ma2532DAz2DqdssfDPsbEIQIhnQCO77FNaKypmFuiWfyeNE8QShgV\n\tEF9VJHO47S8XaLJPmwb82LCn9eqm8p465xHPJE2KRvot4gEeQ+TQ3VL1dF5oA7kV\n\tvgGjxBn/8Eq9BLyMchPmHnSIxWe7qzW/xDjbOMVB3dvV++OS4H2g/g=","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:in-reply-to:references:mime-version:content-type\n\t:content-transfer-encoding:subject:to:from:message-id; s=\n\tdefault; bh=8EJvOUDJdA8Iq8xELpHcc64UbJ0=; b=FAlZmZP0mxBiTGjk+JoM\n\tNN/yBI5QMxhD8bJHpAzso1fh7hku91cfYN9lU00+nb7nwvSfZjsybTBVgGSJrv3G\n\ttZGMlLua76Ff+0kfCeTZ/ORGlF62sjt41DwAWzKGJj+aakad3UKeU/XKs+FZf3Xg\n\t7PdGK+HlRdQe6ECffjBHSsc=","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=-10.1 required=5.0 tests=AWL, BAYES_00,\n\tFREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=HX-Received:10.223.193.14","X-HELO":"mail-wr0-f193.google.com","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net;\n\ts=20161025;\n\th=x-gm-message-state:date:user-agent:in-reply-to:references\n\t:mime-version:content-transfer-encoding:subject:to:from:message-id;\n\tbh=J7mQwl91Sm9OguHOhlRV18nTG7orKqXmF6HfD2H6qN8=;\n\tb=YL0dTHAD9pVtq1h8CXEPLv+XaL/wVV5SZznvuDLZJ6fJkEGM3kxK2Ud+Sl/PJ2+fId\n\tvmvv2OYSx0GB/949xjGSTITD2NmKBri8V3DTFqmrRsuVrFwxf59T8g421vyrydlpV8Xv\n\tgCCq9E7uGB5iQGmdVbmdKtup2/WqNWfzr6K2yo0mGI9beF+RpxgYZTqJbxhmbmV8yp+2\n\tk7txdk6TVWPdxhwPsUn26UkxrAPVViAb13Ojer+veAiaVG8qDDJ91bAXKvPYSkPkL+dy\n\t9MFHXx/hseZF6YpleDW/HffU2/odXHfpXvFONzK/clZZSGnvdPjTlJb2V2mTMM8PWjDj\n\thUyQ==","X-Gm-Message-State":"AHYfb5huoTZBD6tixEcUwvxuORL71p83cGTN0ezRC6gx99iVy9/keSZI\tLxsFZegHSMgWUQ==","X-Received":"by 10.223.193.14 with SMTP id r14mr1772919wre.64.1504121478918;\n\tWed, 30 Aug 2017 12:31:18 -0700 (PDT)","Date":"Wed, 30 Aug 2017 21:31:14 +0200","User-Agent":"K-9 Mail for Android","In-Reply-To":"<e4d087eb-6170-e688-4248-0627f2d2a556@linux.vnet.ibm.com>","References":"<e4d087eb-6170-e688-4248-0627f2d2a556@linux.vnet.ibm.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","Subject":"Re: [PATCH] Fix PR81987 (SLSR dominance issue)","To":"Bill Schmidt <wschmidt@linux.vnet.ibm.com>,\n\tGCC Patches <gcc-patches@gcc.gnu.org>","From":"Richard Biener <richard.guenther@gmail.com>","Message-ID":"<3C61E728-0B35-4F69-82B7-97C73B0BFBA8@gmail.com>","X-IsSubscribed":"yes"}}]