From patchwork Mon Jul 18 12:42:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 37 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a98:d5ce:0:b0:178:cc93:bf7d with SMTP id g14csp1829806eik; Mon, 18 Jul 2022 05:43:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uPz+dIQCD6PFNZSpGnFeBKjRkj9/CviGXUzTTkzznIHrOdK8Iwj/2p8cdV+5mt6yPyf5Mt X-Received: by 2002:a05:6402:3297:b0:43a:9233:23b4 with SMTP id f23-20020a056402329700b0043a923323b4mr36350753eda.397.1658148195971; Mon, 18 Jul 2022 05:43:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658148195; cv=none; d=google.com; s=arc-20160816; b=CHazGkR5WgxJktwQdMrSZbDd5OC/yOOpodva+WZlWJOqYvbgv7nM7uVe14FIKt6QZU IT6TFKD3n8vxB+2CWq82tcO6YUzcLYitGrNkJKJwedoqKuV6fdLLmVXhV2POeVDJFw9c Vh7ghIQOGOfeKPwfGBxzB4G4bkEnk2XR9/WoAR9BcSzOmBVW10pglthNf795dTa95JaI EfIrAuro04A10BowRyUgP87LHwzBADpFKPrI3Ke+xln+IaawpOI6AlNbZkijNZDcUkc/ /QIrIDOjQwjxzhJhTvvfyBCmuTWW/EIjcTFGm6LCZh4giF/832LVUrSe/AgTAa9kwKJp iyig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :user-agent:message-id:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=h22pRK2c0EIy97FYED4K3Xstt6fyeo3lRUa6Q4VRnMs=; b=N/xw5HWdx8tyG0urlGhj0u1SGzNrzywUiA28y3VGCTcZtaEJGgHnqozh2NXF6oDjfQ S44++kX4RnYu93WDUpyjlNAjfK+6MRlZubjn29Qh37elo1qKXr159E039rvnToLKpYed EaUd2OafGGdPHqHoQ4zHI6A8Mgc3YnC3i2N1ID2YB8I7VuDCUdaxalU33Ugt8AnUzn4S g/O+wVv+JCurFKiv4l2fNmzyjTMzFrD+ix/xtoPu3h4VBow7reyT5orfRGjB+rwgyrkK jGDIaBpkJ26b5yLYOeMXes2Mh5yq3Fz02e1cnHv0n3sQ6vyaKmVmymcHEpkMXKHbiyT8 KUrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=T9w8P2VR; 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 sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id gn30-20020a1709070d1e00b0072a9e62a9dfsi15662359ejc.111.2022.07.18.05.43.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 05:43:15 -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=T9w8P2VR; 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 BDF383852770 for ; Mon, 18 Jul 2022 12:43:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BDF383852770 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658148194; bh=h22pRK2c0EIy97FYED4K3Xstt6fyeo3lRUa6Q4VRnMs=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=T9w8P2VRkG26JHvlAe479uyOTqb1v7c0Twmv2UZayl81DDjjrH+lVV3FxVyy4H3lg TRYP8QCgbKcfcUrn0qr2E6IYPVgfnWeGuN/PJPnUF6Sn7RP8nkYZTQJgfjRDE9NXrR fRHCc33q98ZXiriZ4YvdIENJjzDJHbG7hRnZhJqo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 07D873852742 for ; Mon, 18 Jul 2022 12:42:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 07D873852742 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id BCF5E20BC5 for ; Mon, 18 Jul 2022 12:42:30 +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 B78132C141 for ; Mon, 18 Jul 2022 12:42:30 +0000 (UTC) Date: Mon, 18 Jul 2022 12:42:30 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix builtin vs non-builtin partition merge in loop distribution Message-ID: User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: "Li, Pan2 via Gcc-patches" Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1738694402811941260?= X-GMAIL-MSGID: =?utf-8?q?1738694402811941260?= When r7-6373-g40b6bff965d004 fixed a costing issue it failed to make the logic symmetric which means that we now fuse normal vs. builtin when the cost model says so but we don't fuse builtin vs. normal. The following fixes that, also allowing the cost model to decide to fuse two builtin partitions as otherwise an intermediate non-builtin can result in a partial merge as well. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. * tree-loop-distribution.cc (loop_distribution::distribute_loop): When computing cost-based merging do not disregard builtin classified partitions in some cases. * gcc.dg/tree-ssa/ldist-24.c: XFAIL. * gcc.dg/tree-ssa/ldist-36.c: Adjust expected outcome. --- gcc/testsuite/gcc.dg/tree-ssa/ldist-24.c | 5 +++-- gcc/testsuite/gcc.dg/tree-ssa/ldist-36.c | 3 ++- gcc/tree-loop-distribution.cc | 5 +---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ldist-24.c b/gcc/testsuite/gcc.dg/tree-ssa/ldist-24.c index 75f7b8f0c88..2403a24293b 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ldist-24.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ldist-24.c @@ -20,5 +20,6 @@ void foo () } } -/* { dg-final { scan-tree-dump "generated memcpy" "ldist" } } */ -/* { dg-final { scan-tree-dump "generated memset zero" "ldist" } } */ +/* The cost modeling does not consider WAR as beneficial to split. */ +/* { dg-final { scan-tree-dump "generated memcpy" "ldist" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump "generated memset zero" "ldist" { xfail *-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ldist-36.c b/gcc/testsuite/gcc.dg/tree-ssa/ldist-36.c index 07393f0a665..6d560060e09 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ldist-36.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ldist-36.c @@ -25,4 +25,5 @@ foo (struct st * restrict p) } } -/* { dg-final { scan-tree-dump-times "Loop nest . distributed: split to 0 loops and 3 library" 1 "ldist" } } */ +/* The cost modeling doesn't consider splitting a WAR re-use profitable. */ +/* { dg-final { scan-tree-dump-times "Loop nest . distributed: split to 1 loops and 1 library" 1 "ldist" } } */ diff --git a/gcc/tree-loop-distribution.cc b/gcc/tree-loop-distribution.cc index 0714bc41a43..0ee441c077d 100644 --- a/gcc/tree-loop-distribution.cc +++ b/gcc/tree-loop-distribution.cc @@ -3090,10 +3090,7 @@ loop_distribution::distribute_loop (class loop *loop, for (i = 0; partitions.iterate (i, &into); ++i) { bool changed = false; - if (partition_builtin_p (into) || into->kind == PKIND_PARTIAL_MEMSET) - continue; - for (int j = i + 1; - partitions.iterate (j, &partition); ++j) + for (int j = i + 1; partitions.iterate (j, &partition); ++j) { if (share_memory_accesses (rdg, into, partition)) {