From patchwork Wed Sep 14 01:25:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liuhongt X-Patchwork-Id: 1202 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp2605196wrt; Tue, 13 Sep 2022 18:26:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR4zQHqJijgSW5vhrzjismyotvjan9DocdiMa42sqMCeMX3xxZRzsgNWd/73jPI438v5pb76 X-Received: by 2002:a05:6402:520a:b0:450:fcc3:d321 with SMTP id s10-20020a056402520a00b00450fcc3d321mr20011023edd.327.1663118762735; Tue, 13 Sep 2022 18:26:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663118762; cv=none; d=google.com; s=arc-20160816; b=i0cY/rUa0x7rHpe68RTm3l2X0cSYHmoERSiSzmEGQSNbczwOYuLRJI7li12lSta4rc UKyoq5tY+o1QfhzOpS3PygoZf86Z2lqb0GX6HeKDOdny4GeWn0lLE4XG+mN5jTGeiMAW ypAfyS34kxXNPaCAMOa0EPEW2Iw/VJ5c7hxjHpRvA6GDATyfqW7cOulsFx79+ALtZEbp vAdkrSbRqURn/o0Jdb53Phlo4NHR5EnpwT4MXVhboln+qwfCR3KO5wIJ/wgiecP2iWhf vhXp5BHDrxVWFuesBn1mMJzkXOsgkytcjTmOjryc/d9PARNEsJKtoSuoYfay5MIyc6ix Wprw== 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 :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=eQCfOWLfeZYK3Rf/qjCqipWxsyplGQO5Xfh5Zb8VMh8=; b=GYIKt5dDyFDkYV471ExF1jZINUxr968KYsrvxpH2Ia1dJ8Z312dphs06VE6G4GgU69 fL+xUSBsjyGhEvEC097p+gyDbX0A8v0386FdxhC41FvqhqlebOjzd5kkT3nY0RUVmdRZ ytx6DKPoRPY9YIsAPi9K6q9BHxpVomUn6uMQpuK7PPP8aYxC50g/6i3cdtZIvkRLftqd 5lif8dGWNFOc+OP6ARULZsRO+C8QBvv6rIkvoVwIHJ2SV4yR31t4w606gbnz2LLQpZMN h/7WSer9pYeCL2Q/luqIhbG1sPIXa3E5ugCvTsq5FGdA44pIIMc9JP+v/iErlOqm3Qcq w4pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Woq5Wibn; 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 h24-20020a0564020e9800b004512f3e3e03si940291eda.146.2022.09.13.18.26.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Sep 2022 18:26:02 -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=Woq5Wibn; 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 A4B3A3851A96 for ; Wed, 14 Sep 2022 01:26:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A4B3A3851A96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663118761; bh=eQCfOWLfeZYK3Rf/qjCqipWxsyplGQO5Xfh5Zb8VMh8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Woq5Wibni3DM7ZZZkaxRd8M8BTxro2/yvaTMlNX4molhxmfPDtOWhFKrrNrMKhpiW Ktf5fa9h2owtoWP7UU46SQF/WBZmMvuUnnHKp5DBQFzEteRwgSsaQ6VjQ4hin4E9w2 238MbAk7CdRXP2cc+pGoq5HhNfqbYLqLq3qTU/r0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by sourceware.org (Postfix) with ESMTPS id C599D3858D1E for ; Wed, 14 Sep 2022 01:25:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C599D3858D1E X-IronPort-AV: E=McAfee;i="6500,9779,10469"; a="362268224" X-IronPort-AV: E=Sophos;i="5.93,313,1654585200"; d="scan'208";a="362268224" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2022 18:25:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,313,1654585200"; d="scan'208";a="567812644" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by orsmga003.jf.intel.com with ESMTP; 13 Sep 2022 18:25:12 -0700 Received: from shliclel4051.sh.intel.com (shliclel4051.sh.intel.com [10.239.240.51]) by shvmail03.sh.intel.com (Postfix) with ESMTP id 9D3EE10056A0; Wed, 14 Sep 2022 09:25:11 +0800 (CST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] [ICE] Check another epilog variable peeling case in vectorizable_nonlinear_induction. Date: Wed, 14 Sep 2022 09:25:11 +0800 Message-Id: <20220914012511.1012154-1-hongtao.liu@intel.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 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, T_SCC_BODY_TEXT_LINE 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: liuhongt via Gcc-patches From: liuhongt Reply-To: liuhongt Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743906419840810415?= X-GMAIL-MSGID: =?utf-8?q?1743906419840810415?= In vectorizable_nonlinear_induction, r13-2503-gc13223b790bbc5 prevent variable peeling by only checking LOOP_VINFO_MASK_SKIP_NITERS (loop_vinfo). But when "!vect_use_loop_mask_for_alignment_p (loop_vinfo) && LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0", vectorizer will still do variable peeling for epilog, and it hits gcc_assert in vect_peel_nonlinear_iv_init. Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. The patch also fix ICE of the testcase in the PR for ia64-linux-gnu(verified by cross-compile). Ok for trunk? gcc/ChangeLog: PR tree-optimization/106905 * tree-vect-loop.cc (vectorizable_nonlinear_induction): Return false when !vect_use_loop_mask_for_alignment_p (loop_vinfo) && LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0. gcc/testsuite/ChangeLog: * gcc.target/i386/pr106905.c: New test. * gcc.target/ia64/pr106905.c: New test. --- gcc/testsuite/gcc.target/i386/pr106905.c | 14 ++++++++++++++ gcc/testsuite/gcc.target/ia64/pr106905.c | 20 ++++++++++++++++++++ gcc/tree-vect-loop.cc | 6 ++++-- 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr106905.c create mode 100644 gcc/testsuite/gcc.target/ia64/pr106905.c diff --git a/gcc/testsuite/gcc.target/i386/pr106905.c b/gcc/testsuite/gcc.target/i386/pr106905.c new file mode 100644 index 00000000000..a190a1c84e6 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr106905.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-march=silvermont -O2 -fvect-cost-model=dynamic" } */ + +void +foo_mul_peel (int *a, int b) +{ + int i; + + for (i = 0; i < 7; ++i) + { + b *= 2; + a[i] = b; + } +} diff --git a/gcc/testsuite/gcc.target/ia64/pr106905.c b/gcc/testsuite/gcc.target/ia64/pr106905.c new file mode 100644 index 00000000000..1b9656e1203 --- /dev/null +++ b/gcc/testsuite/gcc.target/ia64/pr106905.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -O3 -fPIC" } */ +long ZDICT_fillNoise_p, ZDICT_trainFromBuffer_legacy_result; +unsigned ZDICT_fillNoise_acc; +int ZDICT_totalSampleSize_nbFiles; +static void ZDICT_fillNoise(void *buffer, long length) { + unsigned prime2 = 9; + for (ZDICT_fillNoise_p = 0; ZDICT_fillNoise_p < length; ZDICT_fillNoise_p++) + ZDICT_fillNoise_acc *= ((char *)buffer)[ZDICT_fillNoise_p] = prime2; +} +long ZDICT_trainFromBuffer_legacy() { + void *newBuff; + long total = 0; + for (; ZDICT_totalSampleSize_nbFiles;) + total += 0; + long sBuffSize = total; + newBuff = 0; + ZDICT_fillNoise(newBuff + sBuffSize, 32); + return ZDICT_trainFromBuffer_legacy_result; +} diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 8f88f1755be..9c434b66c5b 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -8646,8 +8646,10 @@ vectorizable_nonlinear_induction (loop_vec_info loop_vinfo, /* Also doens't support peel for neg when niter is variable. ??? generate something like niter_expr & 1 ? init_expr : -init_expr? */ niters_skip = LOOP_VINFO_MASK_SKIP_NITERS (loop_vinfo); - if (niters_skip != NULL_TREE - && TREE_CODE (niters_skip) != INTEGER_CST) + if ((niters_skip != NULL_TREE + && TREE_CODE (niters_skip) != INTEGER_CST) + || (!vect_use_loop_mask_for_alignment_p (loop_vinfo) + && LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0)) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,