From patchwork Thu Aug 24 11:03:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 136805 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp1036541vqm; Thu, 24 Aug 2023 04:04:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IENqWPbpW3croZU5Uwr5k+DTQEEguKX2bE/HKdZ/F5oDCEDrxXc+fkCmkYsKIXaJzQhsR6a X-Received: by 2002:a05:6512:114d:b0:4fd:d08c:fa3e with SMTP id m13-20020a056512114d00b004fdd08cfa3emr15310727lfg.42.1692875067064; Thu, 24 Aug 2023 04:04:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692875067; cv=none; d=google.com; s=arc-20160816; b=KN9HSGw9Eq1vzGFpzb6xBCXUdv2e+0Ke1HiTuqBjvh0fE+q1o2HxKou7PerwnUS5pT 8g+sM5B5FMqFgP/kb0rH08S+lZqqK3E/d3HpwGpT9sfx4qZhd3TqY7Fv/mYKTLxrzTJT lk97y6rf0kTqWQf9jhBcirO9nR/Pqq6v7K4/hYpoVGnlaSm8PdmMhjceDJ72ATIkdCpO Iz6wGtM9shpvkzdvhmsUFxT+Seh0qLWwyja9icn4wmg1Im9ktIXLeMQACeBld4mMMnoY PvbYxDx0uoXSV8fgeahTc728DKNxsWwPLDKdcSrSr5euiuSglP8XE8LeuWB2FASNXKb/ SwlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:sender:errors-to:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:user-agent:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=Udh/GEz42E+K6Ift7KGh488/SnpWPMnLzJgGsLx/WHA=; fh=etb9MYHN7HLF/sff76ICVdPeKiI8ZsjoOL2bcdG0aog=; b=Xrw9JUG+6e93wKSBj24B+I8P8I/bxjMz6j3k9zMbm0Ynjp9rGLKRYbfco0l7tbyCcW yge3pcKjon1aNYZebt4oQRSfnqjvrTNa+fcQujmzSY5SPrtA4mH9Es2LDqXCfAOT1323 Ese9tnEjBmZq6ZbS1957h2TXcrfy0/RrK34NXYaUUAGDh+YfEwY6GJZmy032p9VQ8kR5 O8J+FySr12ZfT1vbHMq2ksPvJ95lZfWovCfPhFAxVcn6PxkPQLji4VxOUrv4Wk4iuvtM YrJnmn4NMwuD7ZKj03NF81PY82vFXWYPV8H5xeRvDgcY2QdlLer7f/YYAKSoYRA09Fao oOfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ACX5tg+3; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id p22-20020a056402075600b0052a1258efdfsi4731932edy.522.2023.08.24.04.04.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 04:04:27 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ACX5tg+3; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ACA0D3851C20 for ; Thu, 24 Aug 2023 11:03:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ACA0D3851C20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692875038; bh=Udh/GEz42E+K6Ift7KGh488/SnpWPMnLzJgGsLx/WHA=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ACX5tg+3kM2v6HqBf3ejJMsuyMtoBEtYGtosV1SJsqPC7CZg5gayv+TcevOisenWu t2u8gC1kKZf5+O2bRI0MHN55SE5SZq4boGbhrPM96NztREHw/90xf25Bq/xYV4Nv7Y lSh5Rk2AIXH0lRT7INxUO03K2XnyGU/zY0eb76xo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 8BE9E3858C39 for ; Thu, 24 Aug 2023 11:03:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8BE9E3858C39 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id A758622D7C for ; Thu, 24 Aug 2023 11:03:06 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id A2B8D2C143 for ; Thu, 24 Aug 2023 11:03:06 +0000 (UTC) Date: Thu, 24 Aug 2023 11:03:06 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/111125 - avoid BB vectorization in novector loops User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" Message-Id: <20230824110358.ACA0D3851C20@sourceware.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1775108166132973313 X-GMAIL-MSGID: 1775108166132973313 When a loop is marked with #pragma GCC novector the following makes sure to also skip BB vectorization for contained blocks. That avoids gcc.dg/vect/bb-slp-29.c failing on aarch64 because of extra BB vectorization therein. I'm not specifically dealing with sub-loops of novector loops, the desired semantics isn't documented. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. Richard. PR tree-optimization/111125 * tree-vect-slp.cc (vect_slp_function): Split at novector loop entry, do not push blocks in novector loops. --- gcc/tree-vect-slp.cc | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index ace0ff3ef60..0b1c2233017 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -7802,6 +7802,17 @@ vect_slp_function (function *fun) bbs[0]->loop_father->num, bb->index); split = true; } + else if (!bbs.is_empty () + && bb->loop_father->header == bb + && bb->loop_father->dont_vectorize) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "splitting region at dont-vectorize loop %d " + "entry at bb%d\n", + bb->loop_father->num, bb->index); + split = true; + } if (split && !bbs.is_empty ()) { @@ -7809,19 +7820,25 @@ vect_slp_function (function *fun) bbs.truncate (0); } - /* We need to be able to insert at the head of the region which - we cannot for region starting with a returns-twice call. */ if (bbs.is_empty ()) - if (gcall *first = safe_dyn_cast (first_stmt (bb))) - if (gimple_call_flags (first) & ECF_RETURNS_TWICE) - { - if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "skipping bb%d as start of region as it " - "starts with returns-twice call\n", - bb->index); - continue; - } + { + /* We need to be able to insert at the head of the region which + we cannot for region starting with a returns-twice call. */ + if (gcall *first = safe_dyn_cast (first_stmt (bb))) + if (gimple_call_flags (first) & ECF_RETURNS_TWICE) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "skipping bb%d as start of region as it " + "starts with returns-twice call\n", + bb->index); + continue; + } + /* If the loop this BB belongs to is marked as not to be vectorized + honor that also for BB vectorization. */ + if (bb->loop_father->dont_vectorize) + continue; + } bbs.safe_push (bb);