Message ID | 20220920233835.45071-1-hongtao.liu@intel.com |
---|---|
State | Accepted, archived |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp1689376wrt; Tue, 20 Sep 2022 16:41:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7v8Kw78xrhNotujoiRw3IpcKn966yoqU+rcQ7BOC5h0Ag1I5/kpXahoaijV8WfkBOBk7iw X-Received: by 2002:a05:6402:4493:b0:451:141d:3231 with SMTP id er19-20020a056402449300b00451141d3231mr21942943edb.318.1663717305409; Tue, 20 Sep 2022 16:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663717305; cv=none; d=google.com; s=arc-20160816; b=fISXc0Q1oS0vDzEBzbi6cMNTYtOLiNJaU7ngnU8mHbGDBCR7QaUibtYCC7RgaNvNsq IffFV8iNUT5RItnpOZoH21F3LJtrrQs2yxmnu/8BPhgVsvt1k0XIJuzvjebazhCcwcTd TLeJuYS4LoIJYmOVaw05zgupgITyL+6s2S9J8sAFV1Sp9rMhQwSmE8d+Cv6fPBBjqAge 6/ftIrJrTE3BFch6LC2ItIbzAH896fN8Hzb59UpzziTWT4rX7RaHthlLj6T7rQI9uPa/ 1Vnmrij5hSKG+c3dt3e0rkXmMc/xkVrJ+AKVgas99LCjN6GFEvgCfokFgbMdxbjS1H6l rGBg== 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:message-id:date :subject:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=meHUeF+IR8R7x0pbmzjzdsrsHjP4wmNM+2E4mm0J3S4=; b=eQChG2irysrj6cQjhq2lO2Dc/EKvc6Jh+DoT0gc+AAL/Z+nIPb696bt21ThP4TRSJi MljXCvwvRPnUHgWSTXVI41PaefsLnPJVsg5K4Xnbdo9B7cqQFOtyJ4jV3+jeqKu9CF3X NoCg73hIGa3RaYi7mFFyoHJYkeU6cpEY7QwYHyuulDM6JDRkkWfYV6oGKKX36Z/5gDAh HRydkrOvelx74V/ivsYVsLgX4CbYApsETXWanoDSNMkBJDvEfA9u1OSANVVlITyKvu4r HZ/or6BybrjPqfiEiijSS0kaXCjwnHjAnMjCW55QQ913Y+rtH8mCz6YUFlEtNu07JvTz z77Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fZMOOp2c; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id sa41-20020a1709076d2900b0077edef76646si869896ejc.366.2022.09.20.16.41.45 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 16:41:45 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fZMOOp2c; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 0584D385801A for <ouuuleilei@gmail.com>; Tue, 20 Sep 2022 23:41:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0584D385801A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663717299; bh=meHUeF+IR8R7x0pbmzjzdsrsHjP4wmNM+2E4mm0J3S4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=fZMOOp2cfaVOXHSVA6g8IcjCEwQeaed4et7RT5NOlCC1GWsEGt3YdstdYXzsvVzNw v/iR4vpUJWdOn8r8eNkn0XcJc1IW7OVrlVXAgAaehcAQqmi++Di8z5PJA8+eBONuuq XiSanvf+oWU8YYjON2n4Dy2nUOx1WeSl/kFuA9m0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by sourceware.org (Postfix) with ESMTPS id CD58A3858C55 for <gcc-patches@gcc.gnu.org>; Tue, 20 Sep 2022 23:40:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CD58A3858C55 X-IronPort-AV: E=McAfee;i="6500,9779,10476"; a="297444041" X-IronPort-AV: E=Sophos;i="5.93,331,1654585200"; d="scan'208";a="297444041" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2022 16:40:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,331,1654585200"; d="scan'208";a="864179042" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by fmsmga006.fm.intel.com with ESMTP; 20 Sep 2022 16:40:36 -0700 Received: from shliclel320.sh.intel.com (shliclel320.sh.intel.com [10.239.240.127]) by shvmail03.sh.intel.com (Postfix) with ESMTP id AE139100513A; Wed, 21 Sep 2022 07:40:35 +0800 (CST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Don't check can_vec_perm_const_p for nonlinear iv_init when it's constant. Date: Wed, 21 Sep 2022 07:38:35 +0800 Message-Id: <20220920233835.45071-1-hongtao.liu@intel.com> X-Mailer: git-send-email 2.18.1 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: liuhongt via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: liuhongt <hongtao.liu@intel.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1744534037501416360?= X-GMAIL-MSGID: =?utf-8?q?1744534037501416360?= |
Series |
Don't check can_vec_perm_const_p for nonlinear iv_init when it's constant.
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patches-check | success | Github commit url |
Commit Message
liuhongt
Sept. 20, 2022, 11:38 p.m. UTC
When init_expr is INTEGER_CST or REAL_CST, can_vec_perm_const_p is not necessary since there's no real vec_perm needed, but vec_gen_perm_mask_checked will gcc_assert (can_vec_perm_const_p). So it's better to use vec_gen_perm_mask_any in vect_create_nonlinear_iv_init. Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. Ok for trunk? gcc/ChangeLog: PR tree-optimization/106963 * tree-vect-loop.cc (vect_create_nonlinear_iv_init): Use vec_gen_perm_mask_any instead of vec_gen_perm_mask_check. gcc/testsuite/ChangeLog: * gcc.target/i386/pr106963.c: New test. --- gcc/testsuite/gcc.target/i386/pr106963.c | 14 ++++++++++++++ gcc/tree-vect-loop.cc | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr106963.c
Comments
On Wed, Sep 21, 2022 at 1:41 AM liuhongt via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > When init_expr is INTEGER_CST or REAL_CST, can_vec_perm_const_p is not > necessary since there's no real vec_perm needed, but > vec_gen_perm_mask_checked will gcc_assert (can_vec_perm_const_p). So > it's better to use vec_gen_perm_mask_any in > vect_create_nonlinear_iv_init. and the VEC_PERM build will fold the permute away? > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > Ok for trunk? OK. Thanks, Richard. > gcc/ChangeLog: > > PR tree-optimization/106963 > * tree-vect-loop.cc (vect_create_nonlinear_iv_init): Use > vec_gen_perm_mask_any instead of vec_gen_perm_mask_check. > > gcc/testsuite/ChangeLog: > > * gcc.target/i386/pr106963.c: New test. > --- > gcc/testsuite/gcc.target/i386/pr106963.c | 14 ++++++++++++++ > gcc/tree-vect-loop.cc | 5 ++++- > 2 files changed, 18 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.target/i386/pr106963.c > > diff --git a/gcc/testsuite/gcc.target/i386/pr106963.c b/gcc/testsuite/gcc.target/i386/pr106963.c > new file mode 100644 > index 00000000000..9f2d20e2523 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/i386/pr106963.c > @@ -0,0 +1,14 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -mavx -mno-avx2" } */ > + > +void > +foo_neg_const (int *a) > +{ > + int i, b = 1; > + > + for (i = 0; i < 1000; i++) > + { > + a[i] = b; > + b = -b; > + } > +} > diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc > index 9c434b66c5b..aabdc6f2d81 100644 > --- a/gcc/tree-vect-loop.cc > +++ b/gcc/tree-vect-loop.cc > @@ -8356,8 +8356,11 @@ vect_create_nonlinear_iv_init (gimple_seq* stmts, tree init_expr, > sel[2 * i + 1] = i + nunits; > } > vec_perm_indices indices (sel, 2, nunits); > + /* Don't use vect_gen_perm_mask_checked since can_vec_perm_const_p may > + fail when vec_init is const vector. In that situation vec_perm is not > + really needed. */ > tree perm_mask_even > - = vect_gen_perm_mask_checked (vectype, indices); > + = vect_gen_perm_mask_any (vectype, indices); > vec_init = gimple_build (stmts, VEC_PERM_EXPR, > vectype, > vec_init, vec_neg, > -- > 2.18.1 >
On Wed, Sep 21, 2022 at 3:41 PM Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > On Wed, Sep 21, 2022 at 1:41 AM liuhongt via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > > When init_expr is INTEGER_CST or REAL_CST, can_vec_perm_const_p is not > > necessary since there's no real vec_perm needed, but > > vec_gen_perm_mask_checked will gcc_assert (can_vec_perm_const_p). So > > it's better to use vec_gen_perm_mask_any in > > vect_create_nonlinear_iv_init. > > and the VEC_PERM build will fold the permute away? Yes, it's just a const vector. [ c, -c, c, c, .. ]. > > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > > Ok for trunk? > > OK. > > Thanks, > Richard. > > > gcc/ChangeLog: > > > > PR tree-optimization/106963 > > * tree-vect-loop.cc (vect_create_nonlinear_iv_init): Use > > vec_gen_perm_mask_any instead of vec_gen_perm_mask_check. > > > > gcc/testsuite/ChangeLog: > > > > * gcc.target/i386/pr106963.c: New test. > > --- > > gcc/testsuite/gcc.target/i386/pr106963.c | 14 ++++++++++++++ > > gcc/tree-vect-loop.cc | 5 ++++- > > 2 files changed, 18 insertions(+), 1 deletion(-) > > create mode 100644 gcc/testsuite/gcc.target/i386/pr106963.c > > > > diff --git a/gcc/testsuite/gcc.target/i386/pr106963.c b/gcc/testsuite/gcc.target/i386/pr106963.c > > new file mode 100644 > > index 00000000000..9f2d20e2523 > > --- /dev/null > > +++ b/gcc/testsuite/gcc.target/i386/pr106963.c > > @@ -0,0 +1,14 @@ > > +/* { dg-do compile } */ > > +/* { dg-options "-O2 -mavx -mno-avx2" } */ > > + > > +void > > +foo_neg_const (int *a) > > +{ > > + int i, b = 1; > > + > > + for (i = 0; i < 1000; i++) > > + { > > + a[i] = b; > > + b = -b; > > + } > > +} > > diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc > > index 9c434b66c5b..aabdc6f2d81 100644 > > --- a/gcc/tree-vect-loop.cc > > +++ b/gcc/tree-vect-loop.cc > > @@ -8356,8 +8356,11 @@ vect_create_nonlinear_iv_init (gimple_seq* stmts, tree init_expr, > > sel[2 * i + 1] = i + nunits; > > } > > vec_perm_indices indices (sel, 2, nunits); > > + /* Don't use vect_gen_perm_mask_checked since can_vec_perm_const_p may > > + fail when vec_init is const vector. In that situation vec_perm is not > > + really needed. */ > > tree perm_mask_even > > - = vect_gen_perm_mask_checked (vectype, indices); > > + = vect_gen_perm_mask_any (vectype, indices); > > vec_init = gimple_build (stmts, VEC_PERM_EXPR, > > vectype, > > vec_init, vec_neg, > > -- > > 2.18.1 > >
diff --git a/gcc/testsuite/gcc.target/i386/pr106963.c b/gcc/testsuite/gcc.target/i386/pr106963.c new file mode 100644 index 00000000000..9f2d20e2523 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr106963.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx -mno-avx2" } */ + +void +foo_neg_const (int *a) +{ + int i, b = 1; + + for (i = 0; i < 1000; i++) + { + a[i] = b; + b = -b; + } +} diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 9c434b66c5b..aabdc6f2d81 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -8356,8 +8356,11 @@ vect_create_nonlinear_iv_init (gimple_seq* stmts, tree init_expr, sel[2 * i + 1] = i + nunits; } vec_perm_indices indices (sel, 2, nunits); + /* Don't use vect_gen_perm_mask_checked since can_vec_perm_const_p may + fail when vec_init is const vector. In that situation vec_perm is not + really needed. */ tree perm_mask_even - = vect_gen_perm_mask_checked (vectype, indices); + = vect_gen_perm_mask_any (vectype, indices); vec_init = gimple_build (stmts, VEC_PERM_EXPR, vectype, vec_init, vec_neg,