From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by sourceware.org (Postfix) with ESMTPS id CD58A3858C55 for ; Tue, 20 Sep 2022 23:40:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CD58A3858C55 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663717254; x=1695253254; h=from:to:cc:subject:date:message-id; bh=3WpbMlQj8Fk/coMQPcNkI84jKDgz0oZwo2cGjsqT4bU=; b=RpZNGk4NEqpll6FbfMncuIVzr0vORwcyOPOYij3JOqDOPzBSl33U2AM1 njBEsCGBtv2rGeQktA8OurWTsN/6idKRcsqtQvYk9f0LTzmdIhGu2qYG4 +OIOEXFqhDCZqfSI+s2Cwn/z1XQ1K+pWbLfuhuOQRqfYsBcNh4/yQxPO8 7VcOq2UGDHJxdlKVq5zDURvpmmK/UNp13X4e0Iqv0NyaOCbmd7Zwr50Mb veqKkzaTJc50aFKUC93+6XUXYwRPOtu5Z6D8hBROZ7x7gd3pNvfdJcjtf l1PtrWXjVzDdjXrNPk+zUnSZ2fOl3+59pP4pEbSR3fmx26M6+qV+P7cEp A==; 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) From: liuhongt To: gcc-patches@gcc.gnu.org Cc: crazylht@gmail.com, hjl.tools@gmail.com 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 List-Id: 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 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