[V2] VECT: Fix ICE of variable stride on strieded load/store with SELECT_VL loop control.
Message ID | 20230706065135.3448078-1-juzhe.zhong@rivai.ai |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2359150vqx; Wed, 5 Jul 2023 23:52:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlET9rD3HZeD2sUxqSMv2QBbLZfmzDL3pIQPtEE9ayx/BXBE9s3nwXuoAL1U63pCacYoEtCP X-Received: by 2002:a17:907:970d:b0:992:b66e:72f9 with SMTP id jg13-20020a170907970d00b00992b66e72f9mr824065ejc.69.1688626331575; Wed, 05 Jul 2023 23:52:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688626331; cv=none; d=google.com; s=arc-20160816; b=Qzuv8mdrYZQ+p15IZ/CfpUauQeyja7SBM1HiYNYyhVg0FbKoYYgZtv+QOabRLklTn6 3nWXM/5uM4eNrIlYmD9aGV10GpH+kRR9uT05X4nksbKJACfnF8VZsbbDMTl43FR0w7EC qwi4ob2mg+aDZsXq7yM7rLSN31HP9tAA9EPm1aNBUgSnLfF6NPOjJOPcN4YBFcRgw1nX CfR7x4dGs4yWxSAs8TsEXAgQomh8Pbkvb0sEVA+wicYABS4gAWOEE6ZwHQNIoGuHoTot SuHk7CJ6JG9Tf4mvZfg7mb/jb1hjNf5PSmGKnNxlRCEC4Q5OYSw1XrB7pYwmVKrh/JtJ VbJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:feedback-id :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dmarc-filter:delivered-to; bh=9GjMAy5npw+JWbTpL2tjGBCOHiSzZSsEerBtFWjVRms=; fh=CHbn33ss3MXGFqXGZpS89+qfBQv2oFkoJCJQmHw6RIo=; b=LarGjneBO/IaiZvUZqneM6pzUikgyAlaZQnLwza7bmJ/UmWWxk47o2ioAw+jb/3WZl OOgpeFRDTle8g1AtSjd6IShI6zZdx4Hk/PbITL96QHOpgqTlTtRa2OvP7tVrAF9ic/mI uwjaRawnzoQD3xMzwKd+GVL0/khzOdJ9KisILhoeJR2DHI4GmquVm1VCaUFCJ5HMzoXD M7u1cLrstEqr2pnzh//0lwEekpPYCDAQXsYnxiWrqt/EwLxmVKClzDtkyiI1kDySWQOb wD7pDPe/qz0578ykVROMVTM9uhpLj7yAp5Qtc6zcmFS3Cgo76iBrUbozhuqB9Pc4n1p9 IeUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id sd10-20020a170906ce2a00b009873cbdd6cfsi385909ejb.706.2023.07.05.23.52.11 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 23:52:11 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5027338555AF for <ouuuleilei@gmail.com>; Thu, 6 Jul 2023 06:52:07 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbguseast1.qq.com (smtpbguseast1.qq.com [54.204.34.129]) by sourceware.org (Postfix) with ESMTPS id 0B81C385771F for <gcc-patches@gcc.gnu.org>; Thu, 6 Jul 2023 06:51:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B81C385771F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivai.ai Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivai.ai X-QQ-mid: bizesmtp72t1688626298t7e1fg4k Received: from rios-cad5.localdomain ( [58.60.1.11]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 06 Jul 2023 14:51:36 +0800 (CST) X-QQ-SSF: 01400000000000G0T000000A0000000 X-QQ-FEAT: CR3LFp2JE4nrKbfE4lrquYFli9inl4HU2mVC5CzELm4pTB8A60RfVTk0J6X23 pmfBWqm5wQ6Sd8TXb3FmojnQ3EKX6EXZiJu+YPwEH+N8lGSMrhD2P8Y4zbfX3uVDMTpE3An ciHSJ0mI17rugESFEsnHTmRQYh+w6FPOJLjZP9HYcFjbhsHtcPdqJQuybsYQ2ZKVg+0lTuJ vXY7Tq4MKpgKyQ6bQnHUDs4T8DwQ/c12aBDJupBxjFYgXcyx4QRd/Mvqq5Hk7Y8YugUiu1F W6H8VdT7jRpcbjYkLWG6p2/1dTkx8wpezUKWNZFUX+PvNv/n3ISiG+6y6hML68ByurqN2dg MRpG7TTsBqPkEqFpwHWhZuJ9Vk8/WdpMT3ZSV3gO3GkA8wN3Yvwoe9j2D1VwzXMjuNvQ75P X-QQ-GoodBg: 2 X-BIZMAIL-ID: 9980193252672963884 From: juzhe.zhong@rivai.ai To: gcc-patches@gcc.gnu.org Cc: richard.sandiford@arm.com, rguenther@suse.de, Ju-Zhe Zhong <juzhe.zhong@rivai.ai> Subject: [PATCH V2] VECT: Fix ICE of variable stride on strieded load/store with SELECT_VL loop control. Date: Thu, 6 Jul 2023 14:51:35 +0800 Message-Id: <20230706065135.3448078-1-juzhe.zhong@rivai.ai> X-Mailer: git-send-email 2.36.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:rivai.ai:qybglogicsvrgz:qybglogicsvrgz7a-one-0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, 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 <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> 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?1770653043800043972?= X-GMAIL-MSGID: =?utf-8?q?1770653043800043972?= |
Series |
[V2] VECT: Fix ICE of variable stride on strieded load/store with SELECT_VL loop control.
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
juzhe.zhong@rivai.ai
July 6, 2023, 6:51 a.m. UTC
From: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
Hi, Richi.
Sorry for making mistake on LEN_MASK_GATHER_LOAD/LEN_MASK_SCATTER_STORE
with SELECT_VL loop control.
Consider this following case:
#define TEST_LOOP(DATA_TYPE, BITS) \
void __attribute__ ((noinline, noclone)) \
f_##DATA_TYPE##_##BITS (DATA_TYPE *restrict dest, DATA_TYPE *restrict src, \
INDEX##BITS stride, INDEX##BITS n) \
{ \
for (INDEX##BITS i = 0; i < n; ++i) \
dest[i] += src[i * stride]; \
}
When "stride" is a constant, current flow works fine.
However, when "stride" is a variable. It causes an ICE:
# vectp_src.67_85 = PHI <vectp_src.67_86(6), src_21(D)(12)>
...
_96 = .SELECT_VL (ivtmp_94, 4);
...
ivtmp_78 = ((sizetype) _39 * (sizetype) _96) * 4;
vect__11.69_87 = .LEN_MASK_GATHER_LOAD (vectp_src.67_85, _84, 4, { 0, 0, 0, 0 }, { -1, -1, -1, -1 }, _96, 0);
...
vectp_src.67_86 = vectp_src.67_85 + ivtmp_78;
Becase the IR: ivtmp_78 = ((sizetype) _39 * (sizetype) _96) * 4;
Instead, I split the IR into:
step_stride = _39
step = step_stride * 4
ivtmp_78 = step * _96
Thanks.
gcc/ChangeLog:
* tree-vect-stmts.cc (vect_get_strided_load_store_ops): Fix ICE.
---
gcc/tree-vect-stmts.cc | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
Comments
On Thu, 6 Jul 2023, juzhe.zhong@rivai.ai wrote: > From: Ju-Zhe Zhong <juzhe.zhong@rivai.ai> > > Hi, Richi. > > Sorry for making mistake on LEN_MASK_GATHER_LOAD/LEN_MASK_SCATTER_STORE > with SELECT_VL loop control. OK. > Consider this following case: > #define TEST_LOOP(DATA_TYPE, BITS) \ > void __attribute__ ((noinline, noclone)) \ > f_##DATA_TYPE##_##BITS (DATA_TYPE *restrict dest, DATA_TYPE *restrict src, \ > INDEX##BITS stride, INDEX##BITS n) \ > { \ > for (INDEX##BITS i = 0; i < n; ++i) \ > dest[i] += src[i * stride]; \ > } > > When "stride" is a constant, current flow works fine. > However, when "stride" is a variable. It causes an ICE: > # vectp_src.67_85 = PHI <vectp_src.67_86(6), src_21(D)(12)> > ... > _96 = .SELECT_VL (ivtmp_94, 4); > ... > ivtmp_78 = ((sizetype) _39 * (sizetype) _96) * 4; > vect__11.69_87 = .LEN_MASK_GATHER_LOAD (vectp_src.67_85, _84, 4, { 0, 0, 0, 0 }, { -1, -1, -1, -1 }, _96, 0); > ... > vectp_src.67_86 = vectp_src.67_85 + ivtmp_78; > > Becase the IR: ivtmp_78 = ((sizetype) _39 * (sizetype) _96) * 4; > > Instead, I split the IR into: > > step_stride = _39 > step = step_stride * 4 > ivtmp_78 = step * _96 > > Thanks. > > gcc/ChangeLog: > > * tree-vect-stmts.cc (vect_get_strided_load_store_ops): Fix ICE. > > --- > gcc/tree-vect-stmts.cc | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc > index c10a4be60eb..10e71178ce7 100644 > --- a/gcc/tree-vect-stmts.cc > +++ b/gcc/tree-vect-stmts.cc > @@ -3176,10 +3176,8 @@ vect_get_strided_load_store_ops (stmt_vec_info stmt_info, > = fold_build2 (MULT_EXPR, sizetype, > fold_convert (sizetype, unshare_expr (DR_STEP (dr))), > loop_len); > - tree bump = make_temp_ssa_name (sizetype, NULL, "ivtmp"); > - gassign *assign = gimple_build_assign (bump, tmp); > - gsi_insert_before (gsi, assign, GSI_SAME_STMT); > - *dataref_bump = bump; > + *dataref_bump = force_gimple_operand_gsi (gsi, tmp, true, NULL_TREE, true, > + GSI_SAME_STMT); > } > else > { >
Committed, thanks Richard. Pan -----Original Message----- From: Gcc-patches <gcc-patches-bounces+pan2.li=intel.com@gcc.gnu.org> On Behalf Of Richard Biener via Gcc-patches Sent: Thursday, July 6, 2023 3:09 PM To: Ju-Zhe Zhong <juzhe.zhong@rivai.ai> Cc: gcc-patches@gcc.gnu.org; richard.sandiford@arm.com Subject: Re: [PATCH V2] VECT: Fix ICE of variable stride on strieded load/store with SELECT_VL loop control. On Thu, 6 Jul 2023, juzhe.zhong@rivai.ai wrote: > From: Ju-Zhe Zhong <juzhe.zhong@rivai.ai> > > Hi, Richi. > > Sorry for making mistake on LEN_MASK_GATHER_LOAD/LEN_MASK_SCATTER_STORE > with SELECT_VL loop control. OK. > Consider this following case: > #define TEST_LOOP(DATA_TYPE, BITS) \ > void __attribute__ ((noinline, noclone)) \ > f_##DATA_TYPE##_##BITS (DATA_TYPE *restrict dest, DATA_TYPE *restrict src, \ > INDEX##BITS stride, INDEX##BITS n) \ > { \ > for (INDEX##BITS i = 0; i < n; ++i) \ > dest[i] += src[i * stride]; \ > } > > When "stride" is a constant, current flow works fine. > However, when "stride" is a variable. It causes an ICE: > # vectp_src.67_85 = PHI <vectp_src.67_86(6), src_21(D)(12)> > ... > _96 = .SELECT_VL (ivtmp_94, 4); > ... > ivtmp_78 = ((sizetype) _39 * (sizetype) _96) * 4; > vect__11.69_87 = .LEN_MASK_GATHER_LOAD (vectp_src.67_85, _84, 4, { 0, 0, 0, 0 }, { -1, -1, -1, -1 }, _96, 0); > ... > vectp_src.67_86 = vectp_src.67_85 + ivtmp_78; > > Becase the IR: ivtmp_78 = ((sizetype) _39 * (sizetype) _96) * 4; > > Instead, I split the IR into: > > step_stride = _39 > step = step_stride * 4 > ivtmp_78 = step * _96 > > Thanks. > > gcc/ChangeLog: > > * tree-vect-stmts.cc (vect_get_strided_load_store_ops): Fix ICE. > > --- > gcc/tree-vect-stmts.cc | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc > index c10a4be60eb..10e71178ce7 100644 > --- a/gcc/tree-vect-stmts.cc > +++ b/gcc/tree-vect-stmts.cc > @@ -3176,10 +3176,8 @@ vect_get_strided_load_store_ops (stmt_vec_info stmt_info, > = fold_build2 (MULT_EXPR, sizetype, > fold_convert (sizetype, unshare_expr (DR_STEP (dr))), > loop_len); > - tree bump = make_temp_ssa_name (sizetype, NULL, "ivtmp"); > - gassign *assign = gimple_build_assign (bump, tmp); > - gsi_insert_before (gsi, assign, GSI_SAME_STMT); > - *dataref_bump = bump; > + *dataref_bump = force_gimple_operand_gsi (gsi, tmp, true, NULL_TREE, true, > + GSI_SAME_STMT); > } > else > { >
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index c10a4be60eb..10e71178ce7 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -3176,10 +3176,8 @@ vect_get_strided_load_store_ops (stmt_vec_info stmt_info, = fold_build2 (MULT_EXPR, sizetype, fold_convert (sizetype, unshare_expr (DR_STEP (dr))), loop_len); - tree bump = make_temp_ssa_name (sizetype, NULL, "ivtmp"); - gassign *assign = gimple_build_assign (bump, tmp); - gsi_insert_before (gsi, assign, GSI_SAME_STMT); - *dataref_bump = bump; + *dataref_bump = force_gimple_operand_gsi (gsi, tmp, true, NULL_TREE, true, + GSI_SAME_STMT); } else {