From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by sourceware.org (Postfix) with ESMTPS id 7F0393858C60 for ; Wed, 1 Dec 2021 13:14:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7F0393858C60 Received: by mail-ed1-x536.google.com with SMTP id o20so100900582eds.10 for ; Wed, 01 Dec 2021 05:14:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=0ghx2Q7ebUTvQFxkntLxD8SwOuuWRcLsVe1K8qmAVc0=; b=tUGpO/2cJYlZcW0WvIq6I53lOA7GQnRuQxHrbv0pHyCzWjRiMdkv0zFpI0NdQlr+Yq Gjkoqfyw/u3ZtypLC3W1ooGv4jpnsoCP2J0K34UATj3oaPa7M2toVX21Y9EuwwiaDQ4F FbfadOGeQ9GU/M+JAaKqeNnZ1FPecPWSIZEx4IltEfMIyYp1QvTSKg9wvzGnytkMq7dT fl/rmiP5QiZPNGrlkV/A/tezBB6iZD5GSGScXGa8GYko8z1QhJVTZ3ifNBRiUrd1uXT8 evYTL2/zYeLggm6NVB2dEaO7v/H6pyJHKqHhT8s7Y+W7cahwji69ncJiDR4UHikxy1+a 1W1g== X-Gm-Message-State: AOAM533odHJODeqFP6UvizvDLYheWsVP15CSyEMystrvpIwuGonY2xDh WeLDRPoR9DujUc80itugATgIypJrqBWGgBx+jYo= X-Google-Smtp-Source: ABdhPJy65+FLredcNv7CX67knZeYJMASQXZ2P3SEAh8mrKpTulZ7pJdW4Q+Do3tuZj2NYYcviPmpKMCLSodAKPtfrdA= X-Received: by 2002:aa7:c313:: with SMTP id l19mr8317071edq.209.1638364482863; Wed, 01 Dec 2021 05:14:42 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Wed, 1 Dec 2021 14:14:32 +0100 Message-ID: Subject: Re: [PATCH] vect: Tighten check for SLP memory groups [PR103517] To: Richard Sandiford , GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, 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, 01 Dec 2021 13:14:46 -0000 On Wed, Dec 1, 2021 at 11:56 AM Richard Sandiford via Gcc-patches wrote: > > When checking for compatible stmts, vect_build_slp_tree_1 did: > > && !(STMT_VINFO_GROUPED_ACCESS (stmt_info) > && (first_stmt_code == ARRAY_REF > || first_stmt_code == BIT_FIELD_REF > || first_stmt_code == INDIRECT_REF > || first_stmt_code == COMPONENT_REF > || first_stmt_code == MEM_REF))) > > That is, it allowed any rhs_code as long as the first_stmt_code > looked valid. This had the effect of allowing IFN_MASK_LOAD > to be paired with an earlier non-call code (but didn't allow > the reverse). > > This patch makes the check symmetrical. > > Still testing on x86_64-linux-gnu. OK if testing passes, or doesn't > this seem like the right approach? It's indeed a too weak comparison of the classification of the first and the followup operands, some larger refactoring is probably needed to improve here (note how we compare STMT_VINFO_GROUPED_ACCESS of the followup against the tree codes of the first stmt but also later compare first_stmt_load_p against load_p). The proposed patch looks reasonable (but then we could drop the STMT_VINFO_GROUPED_ACCESS (stmt_info) part of the check?), so OK. Thanks, Richard. > Richard > > > gcc/ > PR tree-optimization/103517 > * tree-vect-slp.c (vect_build_slp_tree_1): When allowing two > different component references, check the codes of both them, > rather than just the first. > > gcc/testsuite/ > PR tree-optimization/103517 > * gcc.dg/vect/pr103517.c: New test. > --- > gcc/testsuite/gcc.dg/vect/pr103517.c | 13 +++++++++++++ > gcc/tree-vect-slp.c | 7 ++++++- > 2 files changed, 19 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.dg/vect/pr103517.c > > diff --git a/gcc/testsuite/gcc.dg/vect/pr103517.c b/gcc/testsuite/gcc.dg/vect/pr103517.c > new file mode 100644 > index 00000000000..de87fc48f84 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/vect/pr103517.c > @@ -0,0 +1,13 @@ > +/* { dg-do compile } */ > +/* { dg-additional-options "-march=skylake-avx512" { target x86_64-*-* i?86-*-* } } */ > + > +int a; > +short b, c; > +extern short d[]; > +void e() { > + for (short f = 1; f < (short)a; f += 2) > + if (d[f + 1]) { > + b = d[f]; > + c = d[f + 1]; > + } > +} > diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c > index 7bff5118bd0..bc22ffeed82 100644 > --- a/gcc/tree-vect-slp.c > +++ b/gcc/tree-vect-slp.c > @@ -1121,7 +1121,12 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap, > || first_stmt_code == BIT_FIELD_REF > || first_stmt_code == INDIRECT_REF > || first_stmt_code == COMPONENT_REF > - || first_stmt_code == MEM_REF))) > + || first_stmt_code == MEM_REF) > + && (rhs_code == ARRAY_REF > + || rhs_code == BIT_FIELD_REF > + || rhs_code == INDIRECT_REF > + || rhs_code == COMPONENT_REF > + || rhs_code == MEM_REF))) > || first_stmt_load_p != load_p > || first_stmt_phi_p != phi_p) > { > -- > 2.25.1 >