From patchwork Tue Nov 5 12:06:01 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: 1189916 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-512551-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="MRJBvoz9"; 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 4771PW73L1z9sP3 for ; Wed, 6 Nov 2019 07:25: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:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=WVNBB7Ah4qt4B5BZA29WGT7VO2yGrRZAZOauMRac3V9xyLC43Q wU4s8Jyx2S3mrXkmJ4cxuHHK/tXHofw5JoFVDFWu0kc4Otg2MNsMehoAwM/SovCQ heugLShRKFF0iFAQGfmSQZKnQmLw7c8BwEJl01pVd2Dbzru8QWwbTTpy4= 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=xv226GRMGujI/70GXcLfn4ViRhM=; b=MRJBvoz90fKwWIghqQnc Mmh1nvrAcDlMiZ6c1hAC+NEar3kgqgDqCInEoXwiU/z/Ax96RMSDHBodqKjI4nDS GHz1Q35bMM7Ci5wlhE85RQDoYrJZrceS9JDTq7rRnFktw9x9h1IjyGN9bsu+Eanm tg6mCgDcor2/Vv+k/MkF6aM= Received: (qmail 81967 invoked by alias); 5 Nov 2019 20:25: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 81941 invoked by uid 89); 5 Nov 2019 20:24: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, SPF_PASS autolearn=ham version=3.3.1 spammy=cr 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; Tue, 05 Nov 2019 20:24: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 33FC44F2; Tue, 5 Nov 2019 12:24: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 15D6A3FFDD; Tue, 5 Nov 2019 04:06:02 -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: <0bdc7221-6cb7-078f-e0a7-485bd5dbc57c@arm.com> Date: Tue, 5 Nov 2019 12:06:01 +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-05 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-05 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;