From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by sourceware.org (Postfix) with ESMTPS id 0D5B6386483D for ; Thu, 5 Aug 2021 09:36:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0D5B6386483D Received: by mail-io1-xd2c.google.com with SMTP id z7so5849540iog.13 for ; Thu, 05 Aug 2021 02:36:51 -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:cc; bh=jV/usri2bygca/epOkT++dJRy472o49IsRyU2gfdQeU=; b=o8tldr7rMHEwipZFhy7w9hVFtmt4adkl+NPKjUkybMRalB9Mpn3KDPb4Hzvy0FCqzk XFe9u3ivgPSnaO3YUVxkpKfonjboY1zeA05Mxp52e2NeOKZfQUma2H+9gtddKE/cB/Cd nfQN2pUjrUoQFI1uFGKuavAuKfIBVx6izrXNrp6UxTYkmtmwfqcBOi0ZPCJhsbaXmxcy igaX6ErvnlRzTIZlB0LKSOHgs4fkiUeYoL89gtUL1JuuUtDg9/to+rvSoOMnV963idBS HjVX6fl3GZfIYv7eANZ3lO0XgOhZcjHIqvnDYGA17vKk83xeGMBJQR1IT7c88Wo9Ahzj ezPQ== X-Gm-Message-State: AOAM533nvANXR7oCu9YTcWk+OfsQHKxlHVi8ji7kNkQM9fXOdV7hNAfF KGsFL/zRy5wNHVOyvZ+lUb+gvnxM3OJre2FbyQw= X-Google-Smtp-Source: ABdhPJzH5+nCDRdcKiQs9Tq/b4UL4TDpTAM68MbebBzgyBgkUi7N8zy89QpDD/WK5u0hvphinD8Td/tvAY8rAB6wwko= X-Received: by 2002:a02:2348:: with SMTP id u69mr3679229jau.141.1628156210511; Thu, 05 Aug 2021 02:36:50 -0700 (PDT) MIME-Version: 1.0 References: <86pror2n-q58o-n3qs-s9q3-79524p924oo9@fhfr.qr> In-Reply-To: <86pror2n-q58o-n3qs-s9q3-79524p924oo9@fhfr.qr> From: Christophe Lyon Date: Thu, 5 Aug 2021 11:36:39 +0200 Message-ID: Subject: Re: [PATCH] tree-optimization/101756 - avoid vectorizing boolean MAX reductions To: Richard Biener Cc: GCC Patches X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, HTML_MESSAGE, 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 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Thu, 05 Aug 2021 09:36:52 -0000 On Wed, Aug 4, 2021 at 12:33 PM Richard Biener wrote: > The following avoids vectorizing MIN/MAX reductions on bools which, > when ending up as vector(2) would need to be > adjusted because of the sign change. The fix instead avoids any > reduction vectorization where the result isn't compatible > to the original scalar type since we don't compensate for that > either. > > Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. > > 2021-08-04 Richard Biener > > PR tree-optimization/101756 > * tree-vect-slp.c (vectorizable_bb_reduc_epilogue): Make sure > the result of the reduction epilogue is compatible to the original > scalar result. > > * gcc.dg/vect/bb-slp-pr101756.c: New testcase. > Hi, The new testcase fails on aarch64 because: FAIL: gcc.dg/vect/bb-slp-pr101756.c (test for excess errors) Excess errors: /gcc/testsuite/gcc.dg/vect/bb-slp-pr101756.c:4:1: warning: GCC does not currently support mixed size types for 'simd' functions Can you check? Thanks Christophe > --- > gcc/testsuite/gcc.dg/vect/bb-slp-pr101756.c | 15 +++++++++++++++ > gcc/tree-vect-slp.c | 8 +++++--- > 2 files changed, 20 insertions(+), 3 deletions(-) > create mode 100644 gcc/testsuite/gcc.dg/vect/bb-slp-pr101756.c > > diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr101756.c > b/gcc/testsuite/gcc.dg/vect/bb-slp-pr101756.c > new file mode 100644 > index 00000000000..9420e77f64e > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr101756.c > @@ -0,0 +1,15 @@ > +/* { dg-do compile } */ > + > +__attribute__ ((simd)) int > +tq (long int ea, int of, int kk) > +{ > + int bc; > + > + for (bc = 0; bc < 2; ++bc) > + { > + ++ea; > + of |= !!kk < !!ea; > + } > + > + return of; > +} > diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c > index a554c24e0fb..d169bed8e94 100644 > --- a/gcc/tree-vect-slp.c > +++ b/gcc/tree-vect-slp.c > @@ -4847,15 +4847,17 @@ static bool > vectorizable_bb_reduc_epilogue (slp_instance instance, > stmt_vector_for_cost *cost_vec) > { > - enum tree_code reduc_code > - = gimple_assign_rhs_code (instance->root_stmts[0]->stmt); > + gassign *stmt = as_a (instance->root_stmts[0]->stmt); > + enum tree_code reduc_code = gimple_assign_rhs_code (stmt); > if (reduc_code == MINUS_EXPR) > reduc_code = PLUS_EXPR; > internal_fn reduc_fn; > tree vectype = SLP_TREE_VECTYPE (SLP_INSTANCE_TREE (instance)); > if (!reduction_fn_for_scalar_code (reduc_code, &reduc_fn) > || reduc_fn == IFN_LAST > - || !direct_internal_fn_supported_p (reduc_fn, vectype, > OPTIMIZE_FOR_BOTH)) > + || !direct_internal_fn_supported_p (reduc_fn, vectype, > OPTIMIZE_FOR_BOTH) > + || !useless_type_conversion_p (TREE_TYPE (gimple_assign_lhs (stmt)), > + TREE_TYPE (vectype))) > return false; > > /* There's no way to cost a horizontal vector reduction via REDUC_FN so > -- > 2.31.1 >