From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id 70A3A393F82B for ; Wed, 4 Aug 2021 11:48:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 70A3A393F82B Received: by mail-ej1-x633.google.com with SMTP id gs8so3206311ejc.13 for ; Wed, 04 Aug 2021 04:48:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=4uqRHhljfZxjDybRS1X9C9NEcbeH39N2MMd3XvhNFyo=; b=S0+PgOs+L0ooul5JPs9sOaGjOUf0Bp6hekhZn2WEK+5IOZMvGMgCmuq3wz4PeC3zWV q5I13Xiit4zixUI2/ATVlnbcVTdapLyqnSh4LSzX7KmmcFWX4+EN+0BdPvuQL+vJuVW5 7Uc3uk9YFNR9jZ3AlQwtP+pEszYkBXeOUaLEY7N2xkzqF122gh0B1ZsZ8jYUFmFR6HbA GBgDrw3wf26k+0/s13D4Zr/byoVybj9h89tNNOBrVnSMzq/J72/36nnvI0q2ZJ/h7Tm0 A/YVsu0E+6+YpC5oBv6Q76AcsBiCeZpsK2Kk1PQULrWNv5lEUMR+9tOS2YQ5GN/loMwe yjUg== X-Gm-Message-State: AOAM530S+7Hs5IiwafGXMUKDslftRYnFuGzHc6WZp4LXU0hLMHgMq3qy ScTeM+673PAqVG1DwzLE7bz08o+Q4YMdYRxTQIE= X-Google-Smtp-Source: ABdhPJynZoJM46ZnrsvrrTodWgGlwoH+hiZNQaWYmTpyPBchE2RRiA2bGqQqm8nzI6BACyeiLlWnxt220Dr5o9Ykq1M= X-Received: by 2002:a17:906:140e:: with SMTP id p14mr26228623ejc.235.1628077720387; Wed, 04 Aug 2021 04:48:40 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Wed, 4 Aug 2021 13:48:29 +0200 Message-ID: Subject: Re: [PATCH] vect: Tweak comparisons with existing epilogue loops To: Richard Sandiford , GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Wed, 04 Aug 2021 11:48:43 -0000 On Tue, Aug 3, 2021 at 3:52 PM Richard Sandiford via Gcc-patches wrote: > > This patch uses a more accurate scalar iteration estimate when > comparing the epilogue of a constant-iteration loop with a candidate > replacement epilogue. > > In the testcase, the patch prevents a 1-to-3-element SVE epilogue > from seeming better than a 64-bit Advanced SIMD epilogue. > > Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install? OK. Richard. > Richard > > > gcc/ > * tree-vect-loop.c (vect_better_loop_vinfo_p): Detect cases in > which old_loop_vinfo is an epilogue loop that handles a constant > number of iterations. > > gcc/testsuite/ > * gcc.target/aarch64/sve/cost_model_12.c: New test. > --- > .../gcc.target/aarch64/sve/cost_model_12.c | 19 +++++++++++++++++++ > gcc/tree-vect-loop.c | 10 +++++++++- > 2 files changed, 28 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/cost_model_12.c > > diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c > index 0009d0964af..0a5b65adb04 100644 > --- a/gcc/tree-vect-loop.c > +++ b/gcc/tree-vect-loop.c > @@ -2778,7 +2778,15 @@ vect_better_loop_vinfo_p (loop_vec_info new_loop_vinfo, > > /* Limit the VFs to what is likely to be the maximum number of iterations, > to handle cases in which at least one loop_vinfo is fully-masked. */ > - HOST_WIDE_INT estimated_max_niter = likely_max_stmt_executions_int (loop); > + HOST_WIDE_INT estimated_max_niter; > + loop_vec_info main_loop = LOOP_VINFO_ORIG_LOOP_INFO (old_loop_vinfo); > + unsigned HOST_WIDE_INT main_vf; > + if (main_loop > + && LOOP_VINFO_NITERS_KNOWN_P (main_loop) > + && LOOP_VINFO_VECT_FACTOR (main_loop).is_constant (&main_vf)) > + estimated_max_niter = LOOP_VINFO_INT_NITERS (main_loop) % main_vf; > + else > + estimated_max_niter = likely_max_stmt_executions_int (loop); > if (estimated_max_niter != -1) > { > if (known_le (estimated_max_niter, new_vf)) > diff --git a/gcc/testsuite/gcc.target/aarch64/sve/cost_model_12.c b/gcc/testsuite/gcc.target/aarch64/sve/cost_model_12.c > new file mode 100644 > index 00000000000..4c5226e05de > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/sve/cost_model_12.c > @@ -0,0 +1,19 @@ > +/* { dg-options "-O3 -mtune=neoverse-512tvb" } */ > + > +void > +f (float x[restrict 10][1024], > + float y[restrict 10][1024], float z) > +{ > + for (int i = 0; i < 10; ++i) > + { > +#pragma GCC unroll 10 > + for (int j = 0; j < 10; ++j) > + x[j][i] = y[j][i] * z; > + } > +} > + > +/* We should unroll the outer loop, with 2x 16-byte vectors and 1x > + 8-byte vectors. */ > +/* { dg-final { scan-assembler-not {\tptrue\t} } } */ > +/* { dg-final { scan-assembler {\tv[0-9]+\.4s,} } } */ > +/* { dg-final { scan-assembler {\tv[0-9]+\.2s,} } } */