From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id 6498E3858C55 for ; Wed, 21 Sep 2022 07:41:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6498E3858C55 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x531.google.com with SMTP id e17so7357304edc.5 for ; Wed, 21 Sep 2022 00:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=0TlCuWpLpafCsa4KISvqNfXrF0n+XEOZB3b9zld5DJc=; b=apOk+72UmagqiTQ1s9oQqXNC/aGH6kuia/0j55YPUfUihE1E9OpbjUjkUwGIM2Hnfm qbNIHCHWehNxfxyqQyKzw0VfU4WD4ytzilFNLaJChr73fxvTxXlzEGHfnX7wSBxQrFYs 6qL/z7d285B/ED3u6KpOnnMj51XTDDrOkjOM/yy5Gu3QAqSepRJ4E7ONF/gB+tJO9YTC kzhXAm/iwVtukxhc1+UYW3dkR4MCVEVk3rSLXhAdWNiap0CxfIjAJYosxKhCkRQJ6HTa M9j+icMqc21cCwsMpstbQsIP3kaTReKTb7TV3G3RhyvvuGg/eFdZtZrlsnxYmxA69Mfy Erfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=0TlCuWpLpafCsa4KISvqNfXrF0n+XEOZB3b9zld5DJc=; b=gxiufPT10Kqgf7yU9GLnazIUemx80Xlp7gOAwSCRAJZmBqui7nvkQ7zr3Rf6M2grBi Qj05X5sWsXbWYmraT46CO8PkydJJYAQgxYKcIHF3YfKgP2eY8Iy50EYGrMJEhjuX95wI gtekuqKqLciw37x9NJicX5nWExKOSlOgjDUfP2eCyS2CSp/+PGNuxlaN27MkGLiLNobu DULO5EDV8D/V5992pNU2/O3wBdk/OMqIJA6EmSzuYjkJjEg3ZSkQoiTvw2ez62JtFQet 2NdDnTJoe4btFF0teL/y1X2D/FEewpkLWETWW+FCBq90rDonlpPmb6v9QtBqufNJm2Zc B1EA== X-Gm-Message-State: ACrzQf1JQqQjcdWHq+KAjxwCwkTSB34qle+FRLzzOAd3HQDsAhCkWrj0 i0ol3NlF56AENVV8o4JpTz7yqkdIuY74XU2V46s= X-Google-Smtp-Source: AMsMyM7qI29sCOOoAe5RtBEeNO2gAOTJFo7/CRQ6x3/RDG0YL070SLPDFjjP9/9HUkEoUwMJVw3q0BbpV00DO0iyiik= X-Received: by 2002:a05:6402:3786:b0:451:24da:f8c9 with SMTP id et6-20020a056402378600b0045124daf8c9mr23825614edb.250.1663746084029; Wed, 21 Sep 2022 00:41:24 -0700 (PDT) MIME-Version: 1.0 References: <20220920233835.45071-1-hongtao.liu@intel.com> In-Reply-To: <20220920233835.45071-1-hongtao.liu@intel.com> From: Richard Biener Date: Wed, 21 Sep 2022 09:41:11 +0200 Message-ID: Subject: Re: [PATCH] Don't check can_vec_perm_const_p for nonlinear iv_init when it's constant. To: liuhongt Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.1 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, Sep 21, 2022 at 1:41 AM liuhongt via Gcc-patches 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 >