From patchwork Wed Nov 6 10:57:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Andre Vieira (lists)" X-Patchwork-Id: 1190269 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-512579-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="XTMHGfsQ"; 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 477Nmb4zm4z9sP6 for ; Wed, 6 Nov 2019 21:58:07 +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:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=dnZ+p5D0a9+jOrCimNMhjhdLfQ3tb7ZAuMQ3lhuGZUHHx6iaW7 KsrCOwtJ4M37ZGCSupD7Dtjgjddr2LxgABWcWW1m3fGyhtZABSoOBpZXpmcUqw69 6/Gr+nEa+B3ZRYIcx03w32uil5Ki8bAHwCyjUAzSQ2N1YPskyPd5gQrQE= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=So+SC63sAJ3X6vzPAPiE5jUkJwg=; b=XTMHGfsQveiUkxgQZnFW cbi4OPTBn9Fl3j7hip858xV9q9MN/IDNA/eDj9ZfrGMBq31q13WMZMpd0yBW7zvi 9l/E7XF6PHAAnP55XUvN4vTm+eX/3DQwxgewYFfgRuN44e4iIfoNY3qWwv3iSO3B kXv/EBSLrJC8SnPSDq3WNnY= Received: (qmail 13353 invoked by alias); 6 Nov 2019 10:58:00 -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 13335 invoked by uid 89); 6 Nov 2019 10:57:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Nov 2019 10:57:58 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 577247A7; Wed, 6 Nov 2019 02:57:56 -0800 (PST) Received: from [10.2.206.37] (e107157-lin.cambridge.arm.com [10.2.206.37]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CEB603F6C4; Wed, 6 Nov 2019 02:57:55 -0800 (PST) To: gcc-patches Cc: Richard Biener , marxin@gcc.gnu.org From: "Andre Vieira (lists)" Subject: [PATCH][vect] PR92317: fix skip_epilogue creation for epilogues Message-ID: <0da5fc53-8858-18ad-1fc4-b3aeb3c46f12@arm.com> Date: Wed, 6 Nov 2019 10:57:54 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, When investigating PR92317 I noticed that when we create the skip epilogue condition, see ('if (skip_epilog)' in 'vect_do_peeling'), we only copy phi-nodes that are not constants in 'slpeel_update_phi_nodes_for_guard2'. This can cause problems later when we create the scalar epilogue for this epilogue, since if the 'scalar_loop' is not the same as 'loop' 'slpeel_tree_duplicate_loop_to_edge_cfg' will expect both to have identical single_exit bb's and use that to copy the current_def meta_data of phi-nodes. This makes sure that is true even if these phi-nodes are constants, fixing PR92317. I copied the failing testcase and added the options that originally made it fail. Is this OK for trunk? Cheers, Andre gcc/ChangeLog: 2019-11-06 Andre Vieira * tree-vect-loop-manip.c (slpeel_update_phi_nodes_for_guard2): Also update phi's with constant phi arguments. gcc/testsuite/ChangeLog: 2019-11-06 Andre Vieira * gcc/testsuite/g++.dg/opt/pr92317.C diff --git a/gcc/testsuite/g++.dg/opt/pr92317.C b/gcc/testsuite/g++.dg/opt/pr92317.C new file mode 100644 index 0000000000000000000000000000000000000000..2bb9729fc961a998db9a88045ee04a81e12b07a8 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr92317.C @@ -0,0 +1,51 @@ +// Copied from pr87967.C +// { dg-do compile { target c++11 } } +// { dg-options "-O2 -ftree-vectorize -fno-tree-pre --param vect-epilogues-nomask=1" } + +void h(); +template struct k { using d = b; }; +template class> using e = k; +template class f> +using g = typename e::d; +struct l { + template using ab = typename i::j; +}; +struct n : l { + using j = g; +}; +class o { +public: + long r(); +}; +char m; +char s() { + if (m) + return '0'; + return 'A'; +} +class t { +public: + typedef char *ad; + ad m_fn2(); +}; +void fn3() { + char *a; + t b; + bool p = false; + while (*a) { + h(); + o c; + if (*a) + a++; + if (c.r()) { + n::j q; + for (t::ad d = b.m_fn2(), e; d != e; d++) { + char f = *q; + *d = f + s(); + } + p = true; + } + } + if (p) + throw; +} diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c index 1fbcaf2676f3a099cccc5d4f63e18f4a689abeff..54f3ccf3ec373b5621e7778e6e80bab853a57687 100644 --- a/gcc/tree-vect-loop-manip.c +++ b/gcc/tree-vect-loop-manip.c @@ -2291,12 +2291,14 @@ slpeel_update_phi_nodes_for_guard2 (class loop *loop, class loop *epilog, { gphi *update_phi = gsi.phi (); tree old_arg = PHI_ARG_DEF (update_phi, 0); - /* This loop-closed-phi actually doesn't represent a use out of the - loop - the phi arg is a constant. */ - if (TREE_CODE (old_arg) != SSA_NAME) - continue; - tree merge_arg = get_current_def (old_arg); + tree merge_arg = NULL_TREE; + + /* If the old argument is a SSA_NAME use its current_def. */ + if (TREE_CODE (old_arg) == SSA_NAME) + merge_arg = get_current_def (old_arg); + /* If it's a constant or doesn't have a current_def, just use the old + argument. */ if (!merge_arg) merge_arg = old_arg;